Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How to show on a plot minor gridlines with a different thickness?

Assuming I have some data points to plot, say x and y:

import numpy as np

x = np.linspace(0, 1)
y = np.sin(4 * np.pi * x) * np.exp(-5 * x)

I tries plotting them like this:

line(zip(x, y)).show(frame=True, gridlines='minor', axes=False)

In the documentation I read about options for gridlines, including style for vertical and horizontal ones separately, but what about minor and major separation?

What I want is something like this with major lines thicker than minor:

import matplotlib
from matplotlib.pyplot import figure

f = figure(figsize=(8,8))
axes = f.add_axes([.1, .1, .8, .8])

axes.plot(x, y)

axes.grid(True)

axes.get_xaxis().set_minor_locator(matplotlib.ticker.AutoMinorLocator())
axes.get_yaxis().set_minor_locator(matplotlib.ticker.AutoMinorLocator())
axes.grid(b=True, which='minor',  linewidth=.2)
axes.grid(b=True, which='major',  linewidth=1)

f.savefig('plog.png')

How to show on a plot minor gridlines with a different thickness?

Assuming I have some data points to plot, say x and y:

import numpy as np

x = np.linspace(0, 1)
y = np.sin(4 * np.pi * x) * np.exp(-5 * x)

I tries tried plotting them like this:

line(zip(x, y)).show(frame=True, gridlines='minor', axes=False)

In the documentation I read about options for gridlines, including style for vertical and horizontal ones separately, but what about minor and major separation?

What I want is something like this with major lines thicker than minor:

import matplotlib
from matplotlib.pyplot import figure

f = figure(figsize=(8,8))
axes = f.add_axes([.1, .1, .8, .8])

axes.plot(x, y)

axes.grid(True)

axes.get_xaxis().set_minor_locator(matplotlib.ticker.AutoMinorLocator())
axes.get_yaxis().set_minor_locator(matplotlib.ticker.AutoMinorLocator())
axes.grid(b=True, which='minor',  linewidth=.2)
axes.grid(b=True, which='major',  linewidth=1)

f.savefig('plog.png')

How to show on a plot minor gridlines with a different thickness?

Assuming I have some data points to plot, say x and y:

import numpy as np

x = np.linspace(0, 1)
y = np.sin(4 * np.pi * x) * np.exp(-5 * x)

I tried plotting them like this:

line(zip(x, y)).show(frame=True, gridlines='minor', axes=False)

In the documentation I read about options for gridlines, including style for vertical and horizontal ones separately, but what about minor and major separation?

What I want is something like this with major lines thicker than minor:

import matplotlib
from matplotlib.pyplot import figure

f = figure(figsize=(8,8))
axes = f.add_axes([.1, .1, .8, .8])

axes.plot(x, y)

axes.grid(True)

axes.get_xaxis().set_minor_locator(matplotlib.ticker.AutoMinorLocator())
axes.get_yaxis().set_minor_locator(matplotlib.ticker.AutoMinorLocator())
axes.grid(b=True, which='minor',  linewidth=.2)
axes.grid(b=True, which='major',  linewidth=1)

f.savefig('plog.png')

Image: http://postimg.org/image/tgwb8qjsh/

plot