| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Confirmed, however the problem is more nuanced than this. First, the problem does not error-out if one does ax.w_xscale.set_scale('log'), however, this does not set the scale properly because the projection never takes it into account.
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.
@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
issue. However, I would be more than happy to review any patches from those
who can figure this tough nut out.
On Sat, Mar 15, 2014 at 9:51 PM, hyperbowl notifications@github.com wrote:
any progress 3 years later? set_(x,y,z)scale still just sets axis labels,
not axis scaling.Reply to this email directly or view it on GitHubhttps://github.com//issues/209#issuecomment-37745464
.
-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?
As long the bug exists a patch like this could help.
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):
newscale = []
newscale = np.power(10,scale)
if scalename=='x':
plt.xticks(scale,newscale)
if scalename=='y':
plt.yticks(scale,newscale)
if scalename=='z':
plt.zticks(scale,newscale)
scalelog([1,2,3,4],'z')
ax.scatter(xs., ys, np.log(zs), c=c, marker=m)
4 year old bug
workaround:
Z = np.log10(Z) ax.plot_surface(X,Y,Z,cmap=cm.viridis) zticks = [1e-15, 1e-14, 1e-13, 1e-12, 1e-11, 1e-10] ax.set_zticks(np.log10(zticks)) ax.set_zticklabels(zticks)
Played around with this today. The below shows that the grid and ticks are having their data coordinates calculated correctly.
fig = plt.figure()
ax = fig.add_subplot(1, 2, 1)
ax.set(xlim=(1, 100), ylim=(1, 100))
ax.xaxis._set_scale('log')
ax.yaxis._set_scale('log')
ax.grid(True, which='both')
ax = fig.add_subplot(1, 2, 2, projection='3d')
ax.set(xlim=(1, 100), ylim=(1, 100), zlim=(1, 100))
ax.xaxis._set_scale('log')
ax.yaxis._set_scale('log')
ax.zaxis._set_scale('log')However, everything falls apart when I switch from ax.xaxis._set_scale('log') to the proper ax.set_xscale('log'). My impression is that axis3d and axes3d aren't using the transformations at all when doing their calculations, and that'll need to be added in. In other words, there needs to be a separation within all the 3D code between world coordinates and data coordinates. I'm out of my depth to solve this right now, will need someone familiar with how 2D transformations work to be able to implement this. Leaving this info in case these breadcrumbs help anyone.

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 ?
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:
self.plt_ax.zaxis.set_major_formatter(plt.FuncFormatter(lambda val, pos=None: "{:.0f}".format(round(10**val)) if val >= 1 else "{:.1g}".format(10**val)))
stubs = np.array([1,2,3,4,5])
allstubs = np.concatenate([stubs * 10 ** m for m in np.arange(-5.0, 6.0, dtype=float)])
self.plt_ax.zaxis.set_major_locator(plt.FixedLocator(np.log10(allstubs)))
stubs = np.array([1,2,3,4,5,6,7,8,9])
allstubs = np.concatenate([stubs * 10 ** m for m in np.arange(-5.0, 6.0, dtype=float)])
self.plt_ax.zaxis.set_minor_locator(plt.FixedLocator(np.log10(allstubs)))
This would produce axis like this:
Since many people seem to have the problem and it could not be solved in clean way, could it be possible to add the workaround with formatter, locator and ticks as default behavior whenever a log scale is used for a 3D projection ?
@PaulCreusy we would not want to codify a bandaid fiz. But I think that if someone wants to put together a gallery example that shows this workaround to get log axes in 3d in the meantime, it would be very welcome.
This is now available with the release of v3.11. Please see this gallery example for a usage demo: https://matplotlib.org/stable/gallery/mplot3d/scales3d.html
| Back | FazBrowse Home | New Git URL |
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