0

Here is the code

import seaborn as sns
import numpy as np
import matplotlib.pyplot as plt
sns.set_theme()
sns.set_style('dark')

sigma_plot_values = np.linspace(1, 2.8, num=100)


fitted_line = hurdle(sigma_plot_values, beta0, beta1, gamma0, gamma1)
y_2016 = -4 + 5.35*sigma_plot_values


fig = plt.figure(figsize=(10,8), layout='constrained')
plt.xlim(1.0, 2.8)
plt.ylim(-0.5, 11)

plt.plot(sigma_plot_values, fitted_line, color='black')

ax = plt.gca()
        

ax.tick_params(reset=True, direction='in', top=False, right=False)
ax.minorticks_on()
ax.xaxis.set_major_locator(MultipleLocator(0.5))
ax.xaxis.set_major_formatter('{x:.1f}')
ax.xaxis.set_minor_locator(MultipleLocator(0.1))

plt.show()

For some reason, I can never get the minor ticks to show. Here is what I obtain

enter image description here

I would simply like to have major ticks at every 0.5 and minor ticks at every 0.1, but no matter what I try, they never show.

Os GS
  • 69
  • 6
  • Try [increasing the width](https://stackoverflow.com/q/14705904/2476977) of the tick marks – Ben Grossmann Sep 16 '22 at 15:23
  • Can you create a [mcve]? If I use the last 7 lines of your question then the minor ticks show up for me – DavidG Sep 16 '22 at 15:32
  • @DavidG Indeed, i tried with a smaller example and it works. It seems as if the seaborn theme causes the problem. However, now I'm having problems getting the minor ticks at the top – Os GS Sep 16 '22 at 16:10
  • @BenGrossmann I tried it and it doesn't change anything sadly. – Os GS Sep 16 '22 at 16:11
  • @Os You might be able to get things to work by [messing with `plt.rcParams`](https://stackoverflow.com/a/52872625/2476977) – Ben Grossmann Sep 16 '22 at 16:13

0 Answers0