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 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

Reply
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


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