Disable grid on multi-axis log chart

I want to draw a graph with two y scales and a log graph in it. I followed the example given here :

Now I want to turn off the grid, because it looks pretty ugly if I print it on a little paper. However, the grid just does not disappear! If I do this using a non-logarithmic scale, everything is fine, but it somehow doesn't work.

Here is the code:

import numpy as np import matplotlib.pyplot as plt fig = plt.figure() ax1 = fig.add_subplot(111) t = np.arange(0.01, 10.0, 0.01) s1 = np.exp(t) ax1.loglog(t, s1) plt.hold(False) plt.draw() plt.show() 
+4
source share
3 answers

You can use grid ax1.grid(b=False) function ax1.grid(b=False)

+10
source

fig = plt.subplots(m, n, subplot_kw={'xticks': [], 'yticks': []}) # m_by_n grid

0
source

The v1.5.3 documentation on the api axis states the following:

grid(self, b=None, which='major', axis='both', **kwargs)

Turn on or off axis grids; b is boolean. (For MATLAB compatibility, b can also be a string, 'on' or 'off'.)

If b is None and len(kwargs)==0 , switch the state of the grid. If kwargs, it is assumed that you want grid and b to be set to True.

In other words, the call to ax.grid() should turn the grid on and off without having to know the existing state. (To answer the question arbulgazar above. I have a reputation below 50, so I cannot answer with a comment.)

0
source

All Articles