Set the rc parameters using the rc function.
import pylab as p
p.rc(('xtick.major','xtick.minor','ytick.major','ytick.minor'), pad=10)
p.plot([1,2,3])
If you only want to change one of the tick labels, say, the x major ticks, use
p.rc(‘xtick.major), pad=10)
When you’re done and want to reset the rc settings, use
p.rcdefaults()
See matplotlibrc for more settings you can change via the rc command.
Use the scale_x_continuous (or scale_y_continuous) to change tick locations and labels in ggplot.
Change the ticks:
p = ggplot(diamonds)+aes(x=carat,y=price) +
scale_x_continuous(breaks=c(1,1.2,1.5,2.5))
Change the ticks and tick labels:
p = ggplot(diamonds)+aes(x=carat,y=price) +
scale_x_continuous(breaks=c(1,1.2,1.5,2.5), labels=c('a','b','c','d'))
Today I was trying to figure out how to plot two time series with differently scaled values. I found two_scales.py example in the matplotlib examples which describes how to do it.
Here’s a slightly simplified version of the code, and afterward a detailed explanation of what’s going on. Continue reading ‘Create a second y-axis in matplotlib’