Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I increase the line thickness of my Seaborn Line

I have a few seaborn lineplots and I can't figure out how to increase the width of my lines.

Here is my code

#graph 1
sns.lineplot(x="date", y="nps", data=df_nps, ax=ax1, label="NPS", color='#0550D0')
sns.lineplot(x="date", y="ema28", data=df_nps, ax=ax1, label="EMA28", color='#7DF8F3')
sns.lineplot(x="date", y="ema7", data=df_nps, ax=ax1, label="EMA7", color='orange')

#graph 2
dfz_nps_lineplot = sns.lineplot(x="date", y="nps", data=dfz_nps, ax=ax2, label="NPS", color='#0550D0')
dfz_nps_lineplot = sns.lineplot(x="date", y="ema28", data=dfz_nps, ax=ax2, label="EMA28", color='#7DF8F3')
dfz_nps_lineplot = sns.lineplot(x="date", y="ema7", data=dfz_nps, ax=ax2, label="EMA7", color='orange')

#graph3
dfp_nps_lineplot = sns.lineplot(x="date", y="nps", data=dfp_nps, ax=ax3, label="NPS", color='#0550D0')
dfp_nps_lineplot = sns.lineplot(x="date", y="ema28", data=dfp_nps, ax=ax3, label="EMA28", color='#7DF8F3')
dfp_nps_lineplot = sns.lineplot(x="date", y="ema7", data=dfp_nps, ax=ax3, label="EMA7", color='orange')

# formatting

plt.show()

This is what my lineplots look like right now.

https://gyazo.com/1aecfef9e71bfc9d6c0b5f603db93bd1

like image 469
erb13020 Avatar asked Jun 30 '20 22:06

erb13020


People also ask

How do you draw a line in Seaborn?

To draw a line plot in the Seaborn library, the lineplot() function is used. The x attribute of the lineplot() function contains the list of the values to be displayed on the x-axis. For the y-axis, the list of values is passed to the y attribute.

What is Seaborn line plot?

What is a Line Plot? Seaborn as a library is used in Data visualizations from the models built over the dataset to predict the outcome and analyse the variations in the data. Seaborn Line Plots depict the relationship between continuous as well as categorical values in a continuous data point format.


2 Answers

As you can see from seaborn.lineplot documentation, the function accepts matplotlib.axes.Axes.plot() arguments, which means you can pass the same arguments you can to matplotlib function in this documentation.

If you want to simply adjust the width of your lineplots I find this the easiest: pass an argument linewidth = your_desired_line_width_in_float , for example, linewidth = 1.5 in your sns.lineplot() functions.

You can find additional possible arguments in the documentations linked.

Example output on random data:

seaborn.lineplot() without linewdith argument provided searbon.lineplot() without linewdith argument

seaborn.lineplot() with linewidth = 3 seaborn.lineplot() with linewidth = 3

like image 65
dm2 Avatar answered Oct 06 '22 05:10

dm2


You need to specify the linewidth parameter = desired width

like image 34
Michele Giglioni Avatar answered Oct 06 '22 05:10

Michele Giglioni