Purpose of “%matplotlib inline”

%matplotlib is a magic function in IPython. I’ll quote the relevant documentation here for you to read for convenience: IPython has a set of predefined ‘magic functions’ that you can call with a command line style syntax. There are two kinds of magics, line-oriented and cell-oriented. Line magics are prefixed with the % character and … Read more

How to change the font size on a matplotlib plot

From the matplotlib documentation, font = {‘family’ : ‘normal’, ‘weight’ : ‘bold’, ‘size’ : 22} matplotlib.rc(‘font’, **font) This sets the font of all items to the font specified by the kwargs object, font. Alternatively, you could also use the rcParams update method as suggested in this answer: matplotlib.rcParams.update({‘font.size’: 22}) or import matplotlib.pyplot as plt plt.rcParams.update({‘font.size’: … Read more

How do I set the figure title and axes labels font size in Matplotlib?

Functions dealing with text like label, title, etc. accept parameters same as matplotlib.text.Text. For the font size you can use size/fontsize: from matplotlib import pyplot as plt fig = plt.figure() plt.plot(data) fig.suptitle(‘test title’, fontsize=20) plt.xlabel(‘xlabel’, fontsize=18) plt.ylabel(‘ylabel’, fontsize=16) fig.savefig(‘test.jpg’) For globally setting title and label sizes, mpl.rcParams contains axes.titlesize and axes.labelsize. (From the page): axes.titlesize … Read more

How to make IPython notebook matplotlib plot inline

I used %matplotlib inline in the first cell of the notebook and it works. I think you should try: %matplotlib inline import matplotlib import numpy as np import matplotlib.pyplot as plt You can also always start all your IPython kernels in inline mode by default by setting the following config options in your config files: … Read more

Save plot to image file instead of displaying it using Matplotlib

When using matplotlib.pyplot.savefig, the file format can be specified by the extension: from matplotlib import pyplot as plt plt.savefig(‘foo.png’) plt.savefig(‘foo.pdf’) That gives a rasterized or vectorized output respectively. In addition, there is sometimes undesirable whitespace around the image, which can be removed with: plt.savefig(‘foo.png’, bbox_inches=”tight”) Note that if showing the plot, plt.show() should follow plt.savefig(); … Read more

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