Ask Your Question
2

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

asked 2015-03-18 19:42:43 +0100

Eugene gravatar image

updated 2015-03-18 23:43:39 +0100

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

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2015-12-12 16:03:19 +0100

kcrisman gravatar image

I don't think this is possible without using matplotlib in some way inside of Sage. I've opened http://trac.sagemath.org/ticket/19696 for this.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2015-03-18 19:42:43 +0100

Seen: 7,495 times

Last updated: Dec 12 '15