Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Colum items not rendered properly when using a logarithmic Y axis #740

Closed
G30rges opened this issue Jan 18, 2016 · 11 comments · Fixed by #1886 or #1942
Closed

Colum items not rendered properly when using a logarithmic Y axis #740

G30rges opened this issue Jan 18, 2016 · 11 comments · Fixed by #1886 or #1942

Comments

@G30rges
Copy link

G30rges commented Jan 18, 2016

As discussed there: http://discussion.oxyplot.org/topic/1041311-colum-items-not-rendered-properly-when-using-a-logarithmic-y-axis/#

In the oxyplot sample, there are two demos making use of Bars and Columns: BarSeriesDemo and ColumnSeriesDemo.
For the first, using a logarithmic axis in place of the linear one as Y axis does not cause any problem, the values are displayed correctly:

image

However, when doing the same with the demo ColumnSeriesDemo, the bars are not drawn correctly it seems, looks like they are "reversed":
In the class ColumnSeriesDemo.MainWindow, I changed the lines 43 and 44 from
tmp.Axes.Add(new CategoryAxis { ItemsSource = this.Items, LabelField = "Label" });
tmp.Axes.Add(new LinearAxis { Position = AxisPosition.Left, MinimumPadding = 0, AbsoluteMinimum = 0 });
To

tmp.Axes.Add(new CategoryAxis { Position = AxisPosition.Bottom, ItemsSource = this.Items, LabelField = "Label" });
tmp.Axes.Add(new LogarithmicAxis { Position = AxisPosition.Left, Minimum = 1, Base = 10 });

With code behind:
image

With xaml, without the log Y axis:
image

Why doesn't it behave the same way?

@G30rges
Copy link
Author

G30rges commented Jan 18, 2016

For my bars to display "properly", I have to set a base Value = 1 on the series. The problem is I might have values < 1, then they don't get displayed. I need to have a minimum = 0 on the Y axis declaration and the same for the categories values.

@G30rges
Copy link
Author

G30rges commented Feb 2, 2016

Does your commit fix the bug?

Cheers

@objorke
Copy link
Member

objorke commented Feb 2, 2016

No, it was just adding your example reproducing the bug.

objorke added a commit to objorke/oxyplot that referenced this issue Feb 26, 2016
objorke added a commit to objorke/oxyplot that referenced this issue Feb 26, 2016
objorke added a commit to objorke/oxyplot that referenced this issue Feb 26, 2016
@Codebeisser
Copy link

Codebeisser commented Dec 20, 2017

The same issue occurs with stem plot.
See: https://stackoverflow.com/questions/47887366/oxyplot-logarithmic-stem-plot-is-upside-down

@objorke objorke added bug and removed confirmed-bug labels Oct 13, 2019
@udaykolluru
Copy link

udaykolluru commented Dec 10, 2019

@objorke i tried with different graphs with logarithmic axis for area, line, scatter, i can also see the same issue ,is there any fix ,or quick fix for this .

Can you please suggest the fix for the above problem

@VisualMelon
Copy link
Contributor

VisualMelon commented Dec 10, 2019

@udaykolluru which issue exactly? Line, scatter, and 2-line area series should be fine, since they don't need a base-line. It sounds like you may have a different problem: could you provide some example code?


The behaviour described above is certainly inconsistent (which isn't ideal), but logarithmic scales don't have a natural finite zero. Area plots (of which histograms and column plots are different types) usually don't make sense with a logarithmic y-axis, because the area always has to be relative to some baseline.

I'd expect the default behaviour to be that the bar goes on to -infinity (which the data probably is, and is probably causes issues with different renderers: e.g. WPF 'inverting' large and small values is a common symptom), but that's basically of no use to anyone: you need to pick a meaningful baseline; if you don't have a meaningful baseline, then you should probably reconsider using a chart with an area.

Some more commentary on column charts with logarithmic scale can be found in the graph pad guide

@swethakini-ofc
Copy link

swethakini-ofc commented Aug 7, 2020

@VisualMelon @objorke I was trying LogarithmicAxis with HistogramSeries in latest Oxyplot 2.0. The graph looks inverted. How can this be corrected?
Logarithmic Axis
image
Linear Axis
image

@VisualMelon
Copy link
Contributor

VisualMelon commented Aug 7, 2020

@swethakini-ofc HistogramSeries always uses a base value of zero, so it can't be fixed: what is happening is that log(0) is negative infinity. I don't think it makes any sense to use a histogram on a non-linear axis, because the area and height are both meaningful quantities, but if you can explain a use case where a non-zero base would make sense, maybe we could extend it.

@swethakini-ofc
Copy link

@VisualMelon What about Column Series. Even excel provides logarithmic scale for Y axis
image

Excel
image

@VisualMelon
Copy link
Contributor

@swethakini-ofc with column series, you can set the BaseValue to 1 in order to achieve that.

@swethakini-ofc
Copy link

@VisualMelon Thanks this worked 👍

VisualMelon pushed a commit that referenced this issue Aug 13, 2022
…1886)

* Add demo for logarithmic histogram plotting and fix rendering (#740)

* Fix UpdateMinMax for logarithmic scale in HistogramSeries.

* Omit invalid values in HistogramSeries when using logarithmic scale.

* Fix typo in UpdateMaxMinXY for HistogramSeries.
VisualMelon added a commit that referenced this issue May 14, 2023
* Add demo for LinearBarSeries with logarithmic axis.

* Fix for logarithmic LinearBarSeries.

* Fix for padding calculation for logarithmic axis.

* Updated Changelog.

* Use BaseLine and LowestValidRoundTripValue on LogarithmicAxis to render LineBarSeries correctly.

* Better separated box generation from zoom.

---------

Co-authored-by: VisualMelon <VisualMelon@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants