Logarithmic scale with zeros


Author
Message
Fredrik Östlund
Fredrik Östlund
Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)
Group: Forum Members
Posts: 4, Visits: 1
Hi,

I modified a charting library (Chaco) for python before. What needs to be done is:

1) Change the rendering function to plot a vertical line from any point neighboring a zero to the bottom of the plot. That gives the behavior that log zero is mapped to minus infinity.

2) Change the auto scaling the the axis so zeros are ignored.

Just changing zeros to a small value is possible I guess, but less clean. Also, the autoscaling still has to ignore these small values, otherwise the log plot will be dominated by those, leaving the relevant data as a horizontal line at the top.

hope that helps

Fredrik Östlund
Nevron Support
Nevron Support
Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)
Group: Administrators
Posts: 3.1K, Visits: 4.2K

Hi Fredrik,

The behavior of zero values in log axes primarily targets charts with zero scale origin (like bar), which look "good" when zeros are present next to valid values. Sure we can add a mapping function that observes a region of say [0, 0+alpha] and maps it to something that will not generate floating point errors (very large or double.Infinity will cause numeric instability in tick, inflate and other calculations). We'll investigate this further and keep you posted... 



Best Regards,
Nevron Support Team


Fredrik Östlund
Fredrik Östlund
Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)
Group: Forum Members
Posts: 4, Visits: 1
Hi,

I need to plot data in log scale (y-axis, lineseries). My data often contains zeros. I've noticed that when this is the case, the y-axis behaves badly. When there is a zero, the minimum value is set to 1.

When all values are smaller than 1 this fails badly (see example)


var rand = new Random();
var rand_seq = Enumerable.Repeat(0, 100).Select(i => rand.NextDouble()).ToArray();
rand_seq[20] = 0;
var chart = new NCartesianChart();
nChartControl1.Charts.Add(chart);
var line = new NLineSeries();
line.DataLabelStyle.Visible = false;
chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator = new NLogarithmicScaleConfigurator();

chart.Series.Add(line);
line.Values.FillFromEnumerable(rand_seq);
nChartControl1.Refresh();


Also, when using larger values than 1, it seems that the value of log(0) is simply set to 1. This tricks the user into believeing that the data point is 1 instead of zero. What I would like, is a solution where points neighboring log(0) simply are plot with a vertical line (i.e. simulating minus infinity).

Is there any way to achieve this?

best regards

Fredrik Östlund

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search