Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Logarithmic Ticks on Top and Right Spine

I am trying to make a visualization with logarithmic ticks on all sides of the box.

import numpy as np
import matplotlib.pyplot as plt

x  = np.logspace(2, 5, 5)
y  = 0.5*x**(-1/2)
y2 = 0.01*x**(-1/2)
y3 = 0.05*x**(-1/3)

fig, ax = plt.subplots()

ax.plot(x, y, 'o-', label="One")
ax.plot(x, y2, '*-', label="Two")
ax.plot(x, y3, '--', label="Three")

ax.set(
    
    xlabel='Input',
    xlim=(1e2, 1e5),
    xscale='log',
    
    ylabel='Output',
    ylim=(1e-5, 1e-1), 
    yscale='log',   
)

ax.tick_params(top=True, right=True) # <-- This didn't work how I expected.

ax.legend(loc='lower left');

loglogfigure

I would like the associated minor tick marks on the top and right spine.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Any advice on how to make that happen?

>Solution :

Use the which parameter of Axes.tick_params:

ax.tick_params(which='both', top=True, right=True)

Output:

enter image description here

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading