Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Bug]: Axis multiplier when using plot_surface appears outside of the figure window #26100

Closed
@CarrascoCesar

Description

@CarrascoCesar

Bug summary

I am using plot_surface but ran into the issue that when scientific notation is needed, the axis multiplier is offset to the point that it no longer appears in the figure window. I am using matplotlib version 3.7.1 in python 3.11.

Code for reproduction

import matplotlib.pyplot as plt
import numpy as np


ax = plt.figure().add_subplot(projection='3d')

X, Y = np.mgrid[0:6*np.pi:0.25, 0:4*np.pi:0.25]
Z = np.sqrt(np.abs(np.cos(X) + np.cos(Y)))

ax.plot_surface(X * 1e5, Y * 1e5, Z, cmap='autumn',cstride=2, rstride=2)

ax.set_xlabel("X label")
ax.set_ylabel("Y label")
ax.set_zlabel("Z label")
ax.set_zlim(0, 2)

plt.show()

Actual outcome

output

Expected outcome

The x and y axis are missing the 1e6 multiplier. In fact the multiplier is generated but it is actually plotted outside of the limits of the figure window. They can be made to appear by rotating the figure. I am attaching the rotated image showing the two 1e6 multipliers that are plotted far from where they should appear.
FNSxp

Additional information

I am new to python and, while proficient in other programing/scripting languages, I do not feel qualified to look at matplotlib code to figure out where the issue is. I reported this issue in StackOverflow but did not received a possible solution. Probably because I did not do a good job of explaining the issue.

Operating system

MAC OS Ventura 13.4

Matplotlib Version

3.7.1

Matplotlib Backend

MacOSX

Python version

3.11.3

Jupyter version

No response

Installation

conda

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions