How do I fit long title?

Here’s what I’ve finally used: #!/usr/bin/env python3 import matplotlib from matplotlib import pyplot as plt from textwrap import wrap data = range(5) fig = plt.figure() ax = fig.add_subplot(111) ax.plot(data, data) title = ax.set_title(“\n”.join(wrap(“Some really really long long long title I really really need – and just can’t – just can’t – make it any – … Read more

Plotting lines connecting points

I think you’re going to need separate lines for each segment: import numpy as np import matplotlib.pyplot as plt x, y = np.random.random(size=(2,10)) for i in range(0, len(x), 2): plt.plot(x[i:i+2], y[i:i+2], ‘ro-‘) plt.show() (The numpy import is just to set up some random 2×10 sample data)

Annotate data points while plotting from Pandas DataFrame

Here’s a (very) slightly slicker version of Dan Allan’s answer: import matplotlib.pyplot as plt import pandas as pd import numpy as np import string df = pd.DataFrame({‘x’:np.random.rand(10), ‘y’:np.random.rand(10)}, index=list(string.ascii_lowercase[:10])) Which gives: x y a 0.541974 0.042185 b 0.036188 0.775425 c 0.950099 0.888305 d 0.739367 0.638368 e 0.739910 0.596037 f 0.974529 0.111819 g 0.640637 0.161805 h … Read more

pad_inches=0 and bbox_inches=”tight” makes the plot smaller than declared figsize

The problem you are having is that bbox_inches=”tight” just removes all of the extra white space around your figure, it does not actually re-arrange anything in your figure, after it has been rendered. You might need to tweak the parameters you pass to tight_layout (tutorial) to get your desired effect. Hopefully this gets you pointed … Read more

matplotlib strings as labels on x axis

Use the xticks command. import matplotlib.pyplot as plt t11 = [’00’, ’01’, ’02’, ’03’, ’04’, ’05’, ’10’, ’11’, ’12’, ’13’, ’14’, ’15’, ’20’, ’21’, ’22’, ’23’, ’24’, ’25’, ’30’, ’31’, ’32’, ’33’, ’34’, ’35’, ’40’, ’41’, ’42’, ’43’, ’44’, ’45’, ’50’, ’51’, ’52’, ’53’, ’54’, ’55’] t12 = [173, 135, 141, 148, 140, 149, 152, … Read more

inline images have low quality

To change the “%matplotlib inline” figure resolution on the notebook do: import matplotlib as mpl mpl.rcParams[‘figure.dpi’]= dpi I recommend setting the dpi somewhere between 150 and 300 if you are going to download/print the notebook. Ensure that %matplotlib inline runs before the mpl.rcParams[‘figure.dpi’]= dpi otherwise the magic command resets the dpi to its default value … Read more

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