How to change the figure size of a seaborn axes or figure level plot

You can also set figure size by passing dictionary to rc parameter with key ‘figure.figsize’ in seaborn set method: import seaborn as sns sns.set(rc={‘figure.figsize’:(11.7,8.27)}) Other alternative may be to use figure.figsize of rcParams to set figure size as below: from matplotlib import rcParams # figure size in inches rcParams[‘figure.figsize’] = 11.7,8.27 More details can be … Read more

Python matplotlib multiple bars

import matplotlib.pyplot as plt from matplotlib.dates import date2num import datetime x = [ datetime.datetime(2011, 1, 4, 0, 0), datetime.datetime(2011, 1, 5, 0, 0), datetime.datetime(2011, 1, 6, 0, 0) ] x = date2num(x) y = [4, 9, 2] z = [1, 2, 3] k = [11, 12, 13] ax = plt.subplot(111) ax.bar(x-0.2, y, width=0.2, color=”b”, align=’center’) … Read more

How to add a title to a Seaborn boxplot

A Seaborn box plot returns a Matplotlib axes instance. Unlike pyplot itself, which has a method plt.title(), the corresponding argument for an axes is ax.set_title(). Therefore you need to call sns.boxplot(‘Day’, ‘Count’, data=gg).set_title(‘lalala’) A complete example would be: import seaborn as sns import matplotlib.pyplot as plt tips = sns.load_dataset(“tips”) sns.boxplot(x=tips[“total_bill”]).set_title(“LaLaLa”) plt.show() Of course you could … Read more

How to plot multiple dataframes in subplots

You can manually create the subplots with matplotlib, and then plot the dataframes on a specific subplot using the ax keyword. For example for 4 subplots (2×2): import matplotlib.pyplot as plt fig, axes = plt.subplots(nrows=2, ncols=2) df1.plot(ax=axes[0,0]) df2.plot(ax=axes[0,1]) … Here axes is an array which holds the different subplot axes, and you can access one … Read more

How to add hovering annotations to a plot

It seems none of the other answers here actually answer the question. So here is a code that uses a scatter and shows an annotation upon hovering over the scatter points. import matplotlib.pyplot as plt import numpy as np; np.random.seed(1) x = np.random.rand(15) y = np.random.rand(15) names = np.array(list(“ABCDEFGHIJKLMNO”)) c = np.random.randint(1,5,size=15) norm = plt.Normalize(1,4) … Read more

Label axes on Seaborn Barplot

Seaborn’s barplot returns an axis-object (not a figure). This means you can do the following: import pandas as pd import seaborn as sns import matplotlib.pyplot as plt fake = pd.DataFrame({‘cat’: [‘red’, ‘green’, ‘blue’], ‘val’: [1, 2, 3]}) ax = sns.barplot(x = ‘val’, y = ‘cat’, data = fake, color=”black”) ax.set(xlabel=”common xlabel”, ylabel=”common ylabel”) plt.show()

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