How to export plots from matplotlib with transparent background?

Use the matplotlib savefig function with the keyword argument transparent=True to save the image as a png file. In [30]: x = np.linspace(0,6,31) In [31]: y = np.exp(-0.5*x) * np.sin(x) In [32]: plot(x, y, ‘bo-‘) Out[32]: [<matplotlib.lines.Line2D at 0x3f29750>] In [33]: savefig(‘demo.png’, transparent=True) Result: Of course, that plot doesn’t demonstrate the transparency. Here’s a screenshot … Read more

Plot smooth line with PyPlot

You could use scipy.interpolate.spline to smooth out your data yourself: from scipy.interpolate import spline # 300 represents number of points to make between T.min and T.max xnew = np.linspace(T.min(), T.max(), 300) power_smooth = spline(T, power, xnew) plt.plot(xnew,power_smooth) plt.show() spline is deprecated in scipy 0.19.0, use BSpline class instead. Switching from spline to BSpline isn’t a … Read more

Remove plot axis values

Remove numbering on x-axis or y-axis: plot(1:10, xaxt=”n”) plot(1:10, yaxt=”n”) If you want to remove the labels as well: plot(1:10, xaxt=”n”, ann=FALSE) plot(1:10, yaxt=”n”, ann=FALSE)

Rotating axis labels in R

Not sure if this is what you mean, but try setting las=1. Here’s an example: require(grDevices) tN <- table(Ni <- stats::rpois(100, lambda=5)) r <- barplot(tN, col=rainbow(20), las=1) That represents the style of axis labels. (0=parallel, 1=all horizontal, 2=all perpendicular to axis, 3=all vertical)

Force the origin to start at 0

xlim and ylim don’t cut it here. You need to use expand_limits, scale_x_continuous, and scale_y_continuous. Try: df <- data.frame(x = 1:5, y = 1:5) p <- ggplot(df, aes(x, y)) + geom_point() p <- p + expand_limits(x = 0, y = 0) p # not what you are looking for p + scale_x_continuous(expand = c(0, 0)) … Read more

Matplotlib scatterplot; color as a function of a third variable

There’s no need to manually set the colors. Instead, specify a grayscale colormap… import numpy as np import matplotlib.pyplot as plt # Generate data… x = np.random.random(10) y = np.random.random(10) # Plot… plt.scatter(x, y, c=y, s=500) plt.gray() plt.show() Or, if you’d prefer a wider range of colormaps, you can also specify the cmap kwarg to … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)