Best way to plot doublelog data with 0 values?

34 visualizzazioni (ultimi 30 giorni)
Niklas
Niklas il 27 Feb 2020
Modificato: Niklas il 2 Mar 2020
Dear all,
I'm actually a beginner in Matlab and I want to use it to plot simulation data for my Master Thesis. Right now I want to plot neutron spectra resulting from simulations.
Probably not so important for you, but:
These spectra are normalized per primary particle. The y axis is the differential fluence in energy and the x axis is the energy range (which was binned in the simulation). Since the results are in binned form I have to take a stair plot.
My problem is to display values which are zero. I have read much about it and I know that log(0) is infinitely small, however what would be the best way to display my data? If i take a linear scale I will, of course, not see the variation in small values. If I take log this is somewhat misleading since one could interpret 0 values as non-zero values. Does anyone know how this problem is typically solved in Science? Is there a convention about how to treat such things? Could I somehow set the x-axis on the lowest values (0) so that it would be the ground line and I then mention that the groundline has to be interpreted as 0???
This is my Matlab Input:
---
clear all;
clear all;
clc
figure
A=load('File1.txt');
B=load ('File2.txt');
set(gca,'YScale','log');
stairs(B(:,1),A(:,1));
ylim([0 inf])
--
However, note that the input is not so important, it was just for me to get a plot and then trying to play with it in the editor window rather than inducing changes by changing the code. The .txt files are both single column vectors.
I would be very thankful to hear some proper suggestions from you and thank you already for your time.
Kind regards,
Niklas
  3 Commenti
Niklas
Niklas il 27 Feb 2020
Thanks for that answer, it gave me some more understanding. However, what can I do or can I even do something?
dpb
dpb il 27 Feb 2020
Modificato: dpb il 27 Feb 2020
It perhaps would help to know something more about what the actual data ranges are and what it is that is to be considered the important feature to be illustrated by the plot.
As you've alluded to, the log axis will amplify the extremes of the data visually over a linear scale; this is quite commonly used when data are such that their natural range does cover multiple orders of magnitude. OTOH, Guillaume is absolutely correct in that there simply is no way to accurately represent values that are identically zero on a logarithmic axis--they're off in space in whichever direction the (negative) axis is pointing.
If there is structure in a dataset around the origin or other location that is masked by the overall range of the data on a linear scale, oftentimes the presentation method used is to provide an inset of that section of that data with an enlarged scale. Same idea as the inset on a map for city streets.

Accedi per commentare.

Risposte (1)

Prabhan Purwar
Prabhan Purwar il 2 Mar 2020
Hi,
kindly try to project the data upon the shifted logarithmic scale, it will help you in representing sparse data as well as zero value for zero input. I am assuming that data consists of only positive values.
Hope it helps!!
  1 Commento
Niklas
Niklas il 2 Mar 2020
Modificato: Niklas il 2 Mar 2020
Hello,
thanks for your answer. I do not understand what you exactly mean. Yes, my data consists only of positive data. I talked with one of my supervisors, I think I will delete the zero values and consequently summarize the next existent non-zero value after that zero value to a larger bin then. The bin size will not be equal then, but that is a common way more or less if not every energy bin is filled with values. Alternatively I could set a very small number as 0 ground line and I would have to give a comment. I prefer the first solution, so I will delete zero values until the next value is reached. A disadvantage may still be that when I enlarge the bin, one could think that the energy of the neutrons is deposited within this whole bin but indeed it is only in a small place. However I guess if the bin number is high enough this does not play a major role.
Anyhow, this topic seems to be quite complicated and it looks like there is no "perfect" solution. The data is like it is, I have to try to do the best out of it.
Thanks for your answers.

Accedi per commentare.

Categorie

Scopri di più su Two y-axis in Help Center e File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by