dantebarba dantebarba - 1 year ago 125
Python Question

How to set ticks on Fixed Position , matplotlib

Can anyone help me set the ticks on a fixed position using matplotlib? I've tried using FixedPosition as this tutorial describes:

ax = pl.gca()


But when I try to run, it tells me that set_major_locator method does not exist.

A simple example would be very useful.


Answer Source

Just use ax.set_xticks(positions) or ax.set_yticks(positions).

For example:

import matplotlib.pyplot as plt

fig, ax = plt.subplots()
ax.set_xticks([0.15, 0.68, 0.97])
ax.set_yticks([0.2, 0.55, 0.76])

enter image description here

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download