Profile Picture

Logarithmic scale with zeros

Posted By Fredrik Östlund 14 Years Ago
Author
Message
Fredrik Östlund
Posted 14 Years Ago
View Quick Profile
Forum Newbie

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
Last Active: 13 Years Ago
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





Similar Topics


Reading This Topic