Add demo for logarithmic histogram plotting and fix rendering (#740)#1886
Conversation
|
However, it seems the automatic zoom for the graph does not work. Any suggestions how to fix that? |
|
I'd be very wary of this change: logs are confusing enough on bar-charts where only the height is changing when comparing bars: on a histogram, you can have different widths for bins, and a log axis renders the area completely meaningless. What is your use-case for this? Can you describe the behaviour you are seeing and that you expect with the automatic zoom? (not able to test at the moment) If we assume that the bins are constant width, then it could make sense to allow a base-line value as in But again, I don't think logs on a histogram in general make sense. Note that #740 is about bar-graphs, not histograms. It may be that a |
|
Sorry. I should have explained more here. It is basically about what you discussed at the end of #740 with swethakini-ofc. However, the workaround you suggested using the The use case is basically this: I am plotting a measured spectrum that is a histogram and overlay it with a model of the spectrum. Since the height of the bins in a histogram is in y-Unit / x-Unit it corresponds to the model that is also in y-Unit / x-Unit (very common in evaluation of spectra). And now if the baseline of the spectrum is much lower than the peaks, logarithmic plotting allows you to visualize the quality of the fit for low and high intensities of the spectrum at the same time. Additionally, it allows you to visualize regions of equal scaling, since they have the same offset in logarithmic scale (log a*x = log a + log x). So, I want to plot
Both And while the reason given at GraphPad is sensible in the example it gives, it misses the point where it does makes sense to use logarithmic scale. And even if this is not a use case that you accept, it is still wrong how the plotting behaves when using logarithmic y-axis together with Do not get me wrong, I do understand why you hesitate and I can find a way around it, still using oxyplot. Thank you for your time and this great library. |
|
@FabianNitsche thanks for the detail; I can't read it all right now, but I saw you said that Reading a little further, probably not if you need line series as well; linear bar series would be my first guess, but I see you've considered that already. I'll stop rushing and try to provide a proper response later. |
|
You've convinced me this is worth including, and my first instinct is that the most general solution is to allow a base-line for histograms and linear bar series. It certainly makes sense for linear bar series, and for lack of better tools, I can see that the histogram could be useful; in any case, the current behaviour is terrible so we can't be making the situation any worse. Given the weird and inconsistent behaviour at the moment, I think it would be OK to switch between 0 for linear and some default epsilon for logarithmic Y axis, the idea being that the data and the baseline (but not the epsilon if it is used (i.e. no baseline set)) determine the extent of the plot. Rough sketch showing three scenarios: blue dotted box shows the data-extents as I've tried to describe above: for linear it is as is for (I think continuing the bars below the baseline would be a breaking change for (because the epislon is only used for rendering and not for guiding data-points, we have freedom to implement the rendering with them however we want, but if the epsilon method you show in this PR works across all platforms (can't think why it wouldn't, so long as the scale isn't too tight) then its fine by me) Let me know if I've missed the point completely. To achieve this, you'd need to change the If you look at |
|
Thank you for looking into it. I think I get what you are envisioning. I will look into it and update the PR as the next step for discussion. |
|
Just to verify, if I get it correctly, you want a And also fix the UpdateMaxMin accordingly, right? |
|
Yeah, I think that makes sense, but I really want to make sure it works for your use-case, because you're going to be using it and not me. Also, don't feel you have to refit everything: if you're only interested in I think (at least initially) the plots probably need to clamp at the base-line (as in bar-series) if set; we can worry about maybe adding a property to control that later, but with your Epsilon fix and setting the axes manually you can get pretty much achieve the alternative. Most important (with respect to this PR) really are the changes to |
|
I am not so sure about adding However, while I was debugging, I think I found a minor bug that is hindering the auto zoom. In You see, that In our case, we actually do not get into the if, but still Later It is nothing major and your suggestion works very well. So this is probably nothing to be changed. I was just surprised to see |
|
Thanks for the clear explanations. I'm going to be very busy this week, but I'll try to remember to take a proper look at the code soon. Feel free to ping me if I don't get back to you. |
|
Still feels a bit odd, but merged ;) Thanks for this contribution, and sorry I took so long getting back to this. |
|
Re. |
|
Hello! I use the LinearBarSeries with LogarithmicAxis. I use the LinearBarSeries because my x axis is a DateTimeAxis, and I don't have any category axis and I need the DataFieldX, DataFieldY property. :( Any workaround for the bug, until it has fixed? Thanks for your response. |
|
@Dimigergo no plans in any regard. It should be fairly easy using this PR as a reference to update |
|
Hi! I have the same issue, please fix it as soon as possible. Thanks in advance. |
|
I need to look into revising the Histogram fix given #1925 anyway, so may look into this in the next couple of days if I have time. |
|
Hi! |
|
Did you have any chance on looking at the LinearBarSeries? |
|
Sorry, been without a computer for about a week, and probably going to be very busy this week. Keep pestering me and hopefully I'll get around to it, since clearly this is a popular concern. |
|
Ping. :) |
|
I will have a look. |
|
Hello! Is there any milestone for this bug fix? |
|
@Dimigergo no; no milestone. It's high on my list of priorities, but blocking on another issue, and still requires design work so will probably be while before it's finalised. Thanks for the ping in any case ;) |
|
Hello, I see that it is fixed for LinearBarSeries too - that is great news. Can I expect it to be released to nuget.org in the near future? |
|
I have certainly don't have any objections to a new release! |
|
Yes, I think you're right. Should probably add .NET 8 support explicitly as well, which reminds me I was going to take a proper look at #2061 which is very irritating problem at the moment. |




Fixes #740 .
Checklist
Changes proposed in this pull request:
@oxyplot/admins