1

Simple question and I tried a quick search before posting but could not find. I am trying to do a chart and axis Y consists of price. However Y is scaled like attached image and has only 1 decimal. How do I make y axis more precise with 2 decimals and more entries with increment of 0.01?

enter image description here

::Update with code::

# Make the plot

fig, ax = plt.subplots(figsize=(48,32))
ax.scatter(x=times, y=tidy['Price'], c=colors, s=tidy['Volume'] / 4000, alpha=0.4)
ax.ticklabel_format(axis='y', style='plain')
ax.set(
    xlabel='Time',
    xlim=(xmin, xmax),
    ylabel='Price'
)
ax.xaxis.set_major_formatter(DateFormatter('%H:%M'))

1 Answers1

0

One method to increase the number of decimals is to use a formatter for your axis:

from matplotlib.ticker import FormatStrFormatter

ax.yaxis.set_major_formatter(FormatStrFormatter('%.2f'))

However, this method will not increase the number of ticks on your axis. You can set the yticks with .01 increments using the following but you might end up over-saturating the axis might want to increase the increment size.

ax.set_yticks(np.arange(108.30,108.71,.01))
BenT
  • 3,172
  • 3
  • 18
  • 38