âšď¸ Skipped - page is already crawled
| Filter | Status | Condition | Details |
|---|---|---|---|
| HTTP status | PASS | download_http_code = 200 | HTTP 200 |
| Age cutoff | PASS | download_stamp > now() - 6 MONTH | 0 months ago |
| History drop | PASS | isNull(history_drop_reason) | No drop reason |
| Spam/ban | PASS | fh_dont_index != 1 AND ml_spam_score = 0 | ml_spam_score=0 |
| Canonical | PASS | meta_canonical IS NULL OR = '' OR = src_unparsed | Not set |
| Property | Value |
|---|---|
| URL | https://anvil.works/blog/plotting-in-seaborn |
| Last Crawled | 2026-04-12 20:42:10 (12 hours ago) |
| First Indexed | 2020-02-28 11:02:36 (6 years ago) |
| HTTP Status Code | 200 |
| Meta Title | Plotting in Seaborn |
| Meta Description | Anvil is a free Python-based drag-and-drop web app builder |
| Meta Canonical | null |
| Boilerpipe Text | How to make plots using Seaborn
Plotting in Seaborn is much simpler than Matplotlib. While Matplotlib makes the hard things possible, Seaborn
makes the easy things easy by giving you a range of plot types that âjust workâ.
A one-liner⌠almost
Weâre
comparing Python plotting libraries
by making the same plot in each one. Itâs a multi-group bar plot of UK election results.
Hereâs how to create our multi-group bar plot in Seaborn:
ax
=
sns
.
barplot
(
data
=
df
,
x
=
"year"
,
y
=
"seats"
,
hue
=
"party"
,
palette
=
[
'blue'
,
'red'
,
'yellow'
,
'grey'
],
saturation
=
0.6
,
)
Result:
A multi-bar plot, with (almost) one line of Python.
Seaborn has such a simple interface because it doesnât require you to manipulate your data structure in order to
define how your plot looks. Instead, you get your data into
Long Form
, and then your data manipulation
is done. All you need to do is tell Seaborn which aspects of the plot to map to which variables in your data.
If you want to encode the
party
variable in the
hue
of the bars, you specify:
hue
=
"party"
and if you want to encode the
year
variable as position on the x-axis, you specify:
x
=
"year"
The way that Seaborn deals with colours is really interesting. You can specify colours using human-readable colour names.
Weâve used âredâ, âblueâ, âyellowâ and âgreyâ, but you can also use colours like âugly greenâ, âdull blueâ and âelectric purpleâ.
These are mapped to a
crowdsourced library of colour name definitions
created by XKCD
author Randall Munroe.
Just a few of the uncannily accurate XKCD colour names.
For completeness, I must mention that there are a couple of lines of boilerplate to run before the plot statement:
# A couple of lines of boilerplate
sns
.
set
()
plt
.
figure
()
You have to import the library and your data, of course:
# Import Matplotlib and Seaborn
import
matplotlib.pyplot
as
plt
import
seaborn
as
sns
# Import the data in Long Form so that we can treat each variable separately
from
votes
import
long
as
df
And since this is a wrapper around Matplotlib, we still need to cast the Matplotlib plotting spell at the end:
plt
.
show
()
No compromise
Ok, so I have this really beautiful interface that makes common plots really simple. But doesnât that take away my power?
Luckily, thatâs not the case. Seaborn is the good kind of abstraction - it makes the common cases ridiculously easy, but it gives you
access to the lower levels of abstraction when you need it. Just like Anvil, Seaborn gives you
âescape hatchesâ
to use the underlying layers when you need to.
When I called
sns.barplot
, it returned the Matplotlib
Axis
object for that plot. I can use this to add a title,
grid, and tweak the axis labels, just as I did in Matplotlib:
ax
.
set_title
(
'UK election results'
)
ax
.
grid
(
color
=
'#cccccc'
)
ax
.
set_ylabel
(
'Seats'
)
ax
.
set_xlabel
(
None
)
ax
.
set_xticklabels
(
df
[
"year"
]
.
unique
()
.
astype
(
str
),
rotation
=
'vertical'
)
Hereâs the result:
My Seaborn plot, now with Matplotlib tweaks.
You can copy this example as an Anvil app here:
Next: Dynamic plots in client-side Python
Seaborn is one of my favourite plotting libraries, thanks to this combination of simplicity and power. But it produces static images, and if youâre using them on the web we might want a little more interactivity.
Next weâll look at Plotly, which allows you to create of dynamic plots in the browser, with a Python interface
over a JavaScript core: |
| Markdown | - [Solutions](https://anvil.works/blog/plotting-in-seaborn)
Product
- [Features](https://anvil.works/features)
- [Open-source](https://anvil.works/open-source)
- [**Anvil X](https://anvil.works/x)
Use Cases
- [Internal Tools](https://anvil.works/for/internal-tools)
- [Data Science](https://anvil.works/for/data-science)
- [Machine Learning](https://anvil.works/for/machine-learning)
- [New Products](https://anvil.works/for/new-products)
- [Mobile Web Apps](https://anvil.works/for/mobile-web-apps)
- [Education](https://anvil.works/for/education)
- [Pricing](https://anvil.works/pricing)
- [Enterprise](https://anvil.works/blog/plotting-in-seaborn)
- [Anvil for Enterprise](https://anvil.works/enterprise)
- [Case Studies](https://anvil.works/case-studies)
- [Support Plans](https://anvil.works/docs/overview/free-vs-paid#support-plans)
- [Contact Us](mailto:sales@anvil.works?subject=Anvil+Enterprise)
- [Docs](https://anvil.works/docs)
- [Resources](https://anvil.works/blog/plotting-in-seaborn)
Learn
- [Docs](https://anvil.works/docs)
- [Tutorials](https://anvil.works/learn/tutorials)
Explore
- [Examples](https://anvil.works/learn/examples)
- [Blog](https://anvil.works/blog)
- [Community](https://anvil.works/community)
- [Forum](https://anvil.works/forum)
- [Start building](https://anvil.works/build)
[Back]()
- [Solutions](https://anvil.works/blog/plotting-in-seaborn)
- [Pricing](https://anvil.works/pricing)
- [Enterprise](https://anvil.works/blog/plotting-in-seaborn)
- [Docs](https://anvil.works/docs)
- [Resources](https://anvil.works/blog/plotting-in-seaborn)
- [Forum](https://anvil.works/forum)
Product
- [Features](https://anvil.works/features)
- [Open-source](https://anvil.works/open-source)
- [**Anvil X](https://anvil.works/x)
Use Cases
- [Internal Tools](https://anvil.works/for/internal-tools)
- [Data Science](https://anvil.works/for/data-science)
- [Machine Learning](https://anvil.works/for/machine-learning)
- [New Products](https://anvil.works/for/new-products)
- [Mobile Web Apps](https://anvil.works/for/mobile-web-apps)
- [Education](https://anvil.works/for/education)
- [Anvil for Enterprise](https://anvil.works/docs/overview/enterprise)
- [Case Studies](https://anvil.works/case-studies)
- [Support Contracts](https://anvil.works/docs/overview/help#support-contracts)
Learn
- [Docs](https://anvil.works/docs)
- [Tutorials](https://anvil.works/learn/tutorials)
Explore
- [Examples](https://anvil.works/learn/examples)
- [Blog](https://anvil.works/blog)
- [Community](https://anvil.works/community)
[Start building now](https://anvil.works/sign-up)
[Python Plotting Guide](https://anvil.works/blog/plotting-in-python)
# Plotting in Seaborn
 By Shaun
### New to Anvil?
Build web apps with nothing but Python
[Discover Anvil](https://anvil.works/)
[Plotting in Python](https://anvil.works/blog/plotting-in-python)
We're making the same plot in a [range of Python plotting libraries](https://anvil.works/blog/plotting-in-python).
Each library has a different strength - click the buttons below to learn more\!
# How to make plots using Seaborn
Plotting in Seaborn is much simpler than Matplotlib. While Matplotlib makes the hard things possible, Seaborn makes the easy things easy by giving you a range of plot types that âjust workâ.
## A one-liner⌠almost
Weâre [comparing Python plotting libraries](https://anvil.works/blog/plotting-in-python) by making the same plot in each one. Itâs a multi-group bar plot of UK election results.
Hereâs how to create our multi-group bar plot in Seaborn:
```
ax = sns.barplot(
data=df,
x="year",
y="seats",
hue="party",
palette=['blue', 'red', 'yellow', 'grey'],
saturation=0.6,
)
```
Result:

A multi-bar plot, with (almost) one line of Python.
Seaborn has such a simple interface because it doesnât require you to manipulate your data structure in order to define how your plot looks. Instead, you get your data into [Long Form](https://anvil.works/blog/tidy-data), and then your data manipulation is done. All you need to do is tell Seaborn which aspects of the plot to map to which variables in your data.
If you want to encode the `party` variable in the `hue` of the bars, you specify:
```
hue="party"
```
and if you want to encode the `year` variable as position on the x-axis, you specify:
```
x="year"
```
The way that Seaborn deals with colours is really interesting. You can specify colours using human-readable colour names. Weâve used âredâ, âblueâ, âyellowâ and âgreyâ, but you can also use colours like âugly greenâ, âdull blueâ and âelectric purpleâ. These are mapped to a [crowdsourced library of colour name definitions](https://xkcd.com/color/rgb/) created by XKCD author Randall Munroe.

Just a few of the uncannily accurate XKCD colour names.
For completeness, I must mention that there are a couple of lines of boilerplate to run before the plot statement:
```
# A couple of lines of boilerplate
sns.set()
plt.figure()
```
You have to import the library and your data, of course:
```
# Import Matplotlib and Seaborn
import matplotlib.pyplot as plt
import seaborn as sns
# Import the data in Long Form so that we can treat each variable separately
from votes import long as df
```
And since this is a wrapper around Matplotlib, we still need to cast the Matplotlib plotting spell at the end:
```
plt.show()
```
## No compromise
Ok, so I have this really beautiful interface that makes common plots really simple. But doesnât that take away my power? Luckily, thatâs not the case. Seaborn is the good kind of abstraction - it makes the common cases ridiculously easy, but it gives you access to the lower levels of abstraction when you need it. Just like Anvil, Seaborn gives you [âescape hatchesâ](https://anvil.works/blog/escape-hatches-and-ejector-seats) to use the underlying layers when you need to.
When I called `sns.barplot`, it returned the Matplotlib `Axis` object for that plot. I can use this to add a title, grid, and tweak the axis labels, just as I did in Matplotlib:
```
ax.set_title('UK election results')
ax.grid(color='#cccccc')
ax.set_ylabel('Seats')
ax.set_xlabel(None)
ax.set_xticklabels(df["year"].unique().astype(str), rotation='vertical')
```
Hereâs the result:

My Seaborn plot, now with Matplotlib tweaks.
You can copy this example as an Anvil app here:
[Open in Anvil](https://anvil.works/build#clone:JRCSWZ2NSXMX5H6D%3DLMZQ6T3E6ZKJQOI25BHBQIM5)
## Next: Dynamic plots in client-side Python
Seaborn is one of my favourite plotting libraries, thanks to this combination of simplicity and power. But it produces static images, and if youâre using them on the web we might want a little more interactivity.
Next weâll look at Plotly, which allows you to create of dynamic plots in the browser, with a Python interface over a JavaScript core:
[Plotting in Plotly](https://anvil.works/blog/plotting-in-plotly)
[Plotting in Python](https://anvil.works/blog/plotting-in-python)
We're making the same plot in a [range of Python plotting libraries](https://anvil.works/blog/plotting-in-python).
Each library has a different strength - click the buttons below to learn more\!
#### Share this
#### Related content
- Build a Dashboard with Python Read post
- The Easiest Way to Deploy Data Science Read post
- Turning a Jupyter Notebook into a Web App Watch video
TM
#### Develop
- [Build](https://anvil.works/build)
- [Features](https://anvil.works/features)
- [Pricing](https://anvil.works/pricing)
- [Anvil X](https://anvil.works/x)
#### Support
- [Docs](https://anvil.works/docs)
- [Forum](https://anvil.works/forum)
- [Tutorials](https://anvil.works/learn/tutorials)
- [Changelog](https://anvil.works/changelog)
#### Company
- [About us](https://anvil.works/about-us)
- [Jobs](https://anvil.works/jobs)
- [Press](https://anvil.works/press)
- [Contact](https://anvil.works/contact)
Copyright Š 2026 Anvil. Anvil, Anvil Works and our logo are trademarks of The Tuesday Project Ltd.
[Privacy](https://anvil.works/privacy) [Terms of Service](https://anvil.works/terms-of-service) |
| Readable Markdown | ## How to make plots using Seaborn
Plotting in Seaborn is much simpler than Matplotlib. While Matplotlib makes the hard things possible, Seaborn makes the easy things easy by giving you a range of plot types that âjust workâ.
## A one-liner⌠almost
Weâre [comparing Python plotting libraries](https://anvil.works/blog/plotting-in-python) by making the same plot in each one. Itâs a multi-group bar plot of UK election results.
Hereâs how to create our multi-group bar plot in Seaborn:
```
ax = sns.barplot(
data=df,
x="year",
y="seats",
hue="party",
palette=['blue', 'red', 'yellow', 'grey'],
saturation=0.6,
)
```
Result:

A multi-bar plot, with (almost) one line of Python.
Seaborn has such a simple interface because it doesnât require you to manipulate your data structure in order to define how your plot looks. Instead, you get your data into [Long Form](https://anvil.works/blog/tidy-data), and then your data manipulation is done. All you need to do is tell Seaborn which aspects of the plot to map to which variables in your data.
If you want to encode the `party` variable in the `hue` of the bars, you specify:
```
hue="party"
```
and if you want to encode the `year` variable as position on the x-axis, you specify:
```
x="year"
```
The way that Seaborn deals with colours is really interesting. You can specify colours using human-readable colour names. Weâve used âredâ, âblueâ, âyellowâ and âgreyâ, but you can also use colours like âugly greenâ, âdull blueâ and âelectric purpleâ. These are mapped to a [crowdsourced library of colour name definitions](https://xkcd.com/color/rgb/) created by XKCD author Randall Munroe.

Just a few of the uncannily accurate XKCD colour names.
For completeness, I must mention that there are a couple of lines of boilerplate to run before the plot statement:
```
# A couple of lines of boilerplate
sns.set()
plt.figure()
```
You have to import the library and your data, of course:
```
# Import Matplotlib and Seaborn
import matplotlib.pyplot as plt
import seaborn as sns
# Import the data in Long Form so that we can treat each variable separately
from votes import long as df
```
And since this is a wrapper around Matplotlib, we still need to cast the Matplotlib plotting spell at the end:
```
plt.show()
```
## No compromise
Ok, so I have this really beautiful interface that makes common plots really simple. But doesnât that take away my power? Luckily, thatâs not the case. Seaborn is the good kind of abstraction - it makes the common cases ridiculously easy, but it gives you access to the lower levels of abstraction when you need it. Just like Anvil, Seaborn gives you [âescape hatchesâ](https://anvil.works/blog/escape-hatches-and-ejector-seats) to use the underlying layers when you need to.
When I called `sns.barplot`, it returned the Matplotlib `Axis` object for that plot. I can use this to add a title, grid, and tweak the axis labels, just as I did in Matplotlib:
```
ax.set_title('UK election results')
ax.grid(color='#cccccc')
ax.set_ylabel('Seats')
ax.set_xlabel(None)
ax.set_xticklabels(df["year"].unique().astype(str), rotation='vertical')
```
Hereâs the result:

My Seaborn plot, now with Matplotlib tweaks.
You can copy this example as an Anvil app here:
## Next: Dynamic plots in client-side Python
Seaborn is one of my favourite plotting libraries, thanks to this combination of simplicity and power. But it produces static images, and if youâre using them on the web we might want a little more interactivity.
Next weâll look at Plotly, which allows you to create of dynamic plots in the browser, with a Python interface over a JavaScript core: |
| Shard | 50 (laksa) |
| Root Hash | 11086770725442093650 |
| Unparsed URL | works,anvil!/blog/plotting-in-seaborn s443 |