Hello Jean-Philippe,

To complete Amit's reply and in case nobody else already answered your

other question, you can have a look at the following example (the output

is attached as a PDF) that shows:

- How to define tick locators, which can be useful for example when you

do not know in advance what exact values the ticks should have. Please

find more informations in the [official

docs](http://matplotlib.org/api/ticker_api.html). You may also find of

interest these recent examples, about:

* [tick

locators](http://matplotlib.org/examples/ticks_and_spines/tick-locators.html);

* [tick

formatters](matplotlib.org/examples/ticks_and_spines/tick-formatters.html);

- How to invert one of the axes (the z-axis in the example).

```
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
from matplotlib.ticker import (LinearLocator, MaxNLocator,
MultipleLocator)
def dummy_plot(ax):
X, Y = np.meshgrid(np.arange(-5, 5, 0.25), np.arange(-5, 5, 0.25))
Z = np.sin(np.sqrt(X**2 + Y**2))
ax.plot_surface(X, Y, Z, cmap='coolwarm')
return ax
fig = plt.figure("Demo_Jean-Philippe_GRIVET", figsize=(4.8 * 3, 4.8))
ax0 = fig.add_subplot(1, 3, 1, projection='3d')
ax0 = dummy_plot(ax0)
ax0.set_title('Vanilla plot')
ax1 = fig.add_subplot(1, 3, 2, projection='3d')
ax1 = dummy_plot(ax1)
ax1.set_title('Custom locators')
ax1.set_xlabel('LinearLocator') # evenly spaced ticks from min to max
ax1.xaxis.set_major_locator(LinearLocator(numticks=5))
ax1.set_ylabel('MaxNLocator') # use up to nbins+1 ticks at nice locs
ax1.yaxis.set_major_locator(MaxNLocator(nbins=5, symmetric=True,
integer=True))
ax1.set_zlabel('MultipleLocator') # ticks/range are a multiple of base
ax1.zaxis.set_major_locator(MultipleLocator(base=0.4))
ax2 = fig.add_subplot(1, 3, 3, projection='3d')
ax2 = dummy_plot(ax2)
ax2.set_title('Inverted z-axis')
ax2.invert_zaxis()
# From looking at the code, it is equivalent to:
# bottom, top = ax2.get_zlim()
# ax2.set_zlim(top, bottom, auto=None)
plt.tight_layout()
plt.show()
```

Best,

Adrien

Try using the methods 'set_xticks', 'set_yticks' and 'set_zticks' of the

Axes object.

Each of them accepts a list of values that will be displayed.

For example:

ax.set_xticks(np.r_[-10:10:3j])

Will display ticks for values -10,0 and 10 only.

Hello,

I have two questions related to axes in a 3-D plot.

1. I often find that ticks are too close together so that labels

overlap. How

can I change the number of ticks or the step length ?

2. The default axes lay-out has x increasing from left to right and y

increasing

from front to back. My finction decrease quickly with increasing y, so

that the

corresponding parts of the surface are hidden. Therefore, I would like

to have

y values increasing from back to front. I understand that yaxis_invert

can do it

but how is it used ?

Thank you for your help

Jean-Philippe

_______________________________________________

Matplotlib-users mailing list

Matplotlib-users at python.org

https://mail.python.org/mailman/listinfo/matplotlib-users

_______________________________________________

Matplotlib-users mailing list

Matplotlib-users at python.org

https://mail.python.org/mailman/listinfo/matplotlib-users

-------------- next part --------------

A non-text attachment was scrubbed...

Name: Demo_Jean-Philippe_GRIVET.pdf

Type: application/pdf

Size: 183486 bytes

Desc: not available

URL: <http://mail.python.org/pipermail/matplotlib-users/attachments/20170315/a9fb9671/attachment-0001.pdf>

## ···

On 14/03/2017 16:43, Amit Yaron wrote:

On 11/03/17 19:54, Jean-Philippe GRIVET wrote: