-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
3D scatter plots don't work in logscale #209
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
Comments
Confirmed, however the problem is more nuanced than this. First, the problem does not error-out if one does Calling ax.set_xscale (or ax.set_yscale) appears to trigger some other stuff that leads to an error for displaying the coordinates in the corner. ax.set_zscale does not appear to exist. However, given that scaling does not appear to work properly right now, I am not inclined to add it. |
Well... it is better than it used to be. The issue is that there is a lot of code in mplot3d that just completely ignores the projection information of the axes. While significant progress has been made in axes3d.py, it is axis3d.py that still needs a lot of TLC. |
@gllor or @WeatherGod t, I am facing the same problem (and hence is happy to find this discussion).. could you finally got it to work? Getting the 3d plot with data logarithmically rescaled?? |
@Panchie I'm sorry I cannot shed more light into the issue, I didn't get it working and didn't find any solution googling around. |
+1 on this issue, stuck with exactly this problem |
I would also like to see this issue resolved. |
The problem is till there apparently. It is a big issue for me. I hope someone could resolve it soon. |
any progress 3 years later? set_(x,y,z)scale still just sets axis labels, not axis scaling. |
Unfortunately, no. I have not had the time or the resources to address this On Sat, Mar 15, 2014 at 9:51 PM, hyperbowl [email protected] wrote:
|
-1, just kidding, the log won't work with that π. The problem described sounds like a very simple problem, I mean as all the axes exist orthogonal to one another the problem should in theory exist no different for 3d as for 2d or for that matter any number of plotable dimensions. The fact that this problem has lasted so long tells me that the code says otherwise, in which case I imagine, as with a lot of the codebase, it needs a refactor, the good news I like doing. The biggest problem though lies in the amount that needs refactoring. Starting at the base and working our way up, with bringing tools out of the backend (MEP 22) finished and general backend refactoring (MEP 27) on its way, I guess the main plotting functions will come next. As @WeatherGod says, if anyone feels like jump in and looking through the code, then feel free (I only jumped in about a month or two ago myself), we can give guidance if needed and it works a lot better than +1s π. |
how hard would it be to make a workaround which prevents all set_scale('log') in 3D and calls a module which calculates the affected data array log (e.g. np.log(data) ) and changes the ticks labels to decimal power? I will try to add an extra module in my 3D Scripts, where the data and fixed scale values will be modified, sth like this: def scalelog(scale,scalename): scalelog([1,2,3,4],'z') |
4 year old bug workaround:
|
@Teque5 |
@tommyhlw
To those watching from the bleachers, ideally we would just have to add |
@tommyhlw, @JesterEE, and @erikliland, you are invited to submit a pull request that solves the problem cleanly. It might be relatively easy, by following how the scale is handled on the x and y axes in normal mpl 2-D plotting, using the appropriate Locator and Formatter. Or it might get tricky and complicated--I suspect it would. But until you or one of the other people interested in this feature submit a pull request, then chances are the feature will not be added. |
For anyone stumbling on this issue, the easiest workaround IMO is to plot the data using import matplotlib.ticker as mticker
ax.plot_surface(x, y, np.log10(z))
def log_tick_formatter(val, pos=None):
return "{:.2e}".format(10**val)
ax.zaxis.set_major_formatter(mticker.FuncFormatter(log_tick_formatter)) Unfortunately I don't have the time at the moment to solve the problem in mplot3d and submit a pull request. |
I just removed about 16 comments with no content other than "+1", If you run into this issue and would like to express that you've experienced the same issue, please do not add a comment simply saying "+1". It adds nothing to move progress forward and alerts at least 30 developers with a new, notification that isn't worth much. Instead, please use the reaction buttons in the upper right corner of the boxes of the already posted comments. |
The lack of resolution is frustrating to someone who wants to make log-scaled 3d histograms ... but completely understandable. It would be cool if we could do something like donate to matplotlib with some small percentage of the donation earmarked as a bounty for particular bugs. Speaking of which, I just donated a small amount to matplotlib because matplotlib is awesome, as are the developers. |
Thank you very much for your donation @mglerner. I very much understand your frustration. I would very much like to resolve this bug, but as a freelancer I don't have the time at the moment to volunteer my services to actively develop MPL. One day I hope to return :). |
You could use the return statement below if you want a nicer format def log_tick_formatter(val, pos=None):
return r"$10^{:.0f}$".format(val) |
This formatter only works if the value is a single character, if the value is 10 it will format 10^10=10^{1} 0 and not 10^{10}. You need three curly brackets for it to work (double curly brackets are literal curly brackets, {{ to print the character { ): def log_tick_formatter(val, pos=None):
return r"$10^{{{:.0f}}}$".format(val) |
It is very unfortunate that the 3D projection behaves differently from the 2D "projection". Makes it hard to write code that is transparent w/r dimensionality of axes. |
Hi, is there any news about this issue or is this still an open subject ? |
Unfortunately this bug and many others #12620 are a decade old and nobody understands the 3d plotter internals enough to fix. Mayavi seems to be everyone's favorite alternative for 3d, although the interface is super janky compared to matplotlib. Recently I've taken to exporting these kinds of plots to Blender. |
Thirteen years later, I'm having the same issue. Hope this gets solved eventually, matplotlib is great otherwise! |
I gave it my best shot, but am unable to continue working on it. If anyone wants to build on it, be my guest! π |
Thank you for your efforts @AnsonTran! |
I wish this function would work. Meanwhie: as said aboves it is possible to cicumvent the problem by putting log10(z) in z and with these tweaking grid and text:
This would produce axis like this: |
Original report at SourceForge, opened Fri Jun 10 12:29:24 2011
If you enable a log scale when doing a 3D scatter plot, nothing is created and the program crashes. Attached is the error output.
You can easily reproduce this by taking the example scatter3d_demo.py and adding the line "ax.set_xscale('log')".
SourceForge History
The text was updated successfully, but these errors were encountered: