Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions examples/faceted_lineplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@
Line plots on multiple facets
=============================

_thumb: .45, .42
_thumb: .48, .42

"""
import seaborn as sns
sns.set(style="ticks")

dots = sns.load_dataset("dots")

# Define a palette to ensure that colors will be
# shared across the facets
palette = dict(zip(dots.coherence.unique(),
sns.color_palette("rocket_r", len(dots.coherence.unique()))))
# Define the palette as a list to specify exact values
palette = sns.color_palette("rocket_r")

# Plot the lines on two facets
sns.relplot(x="time", y="firing_rate",
hue="coherence", size="choice", col="align",
size_order=["T1", "T2"], palette=palette,
height=5, aspect=.75, facet_kws=dict(sharex=False),
kind="line", legend="full", data=dots)
sns.relplot(
data=dots,
x="time", y="firing_rate",
hue="coherence", size="choice", col="align",
kind="line", size_order=["T1", "T2"], palette=palette,
height=5, aspect=.75, facet_kws=dict(sharex=False),
)
2 changes: 1 addition & 1 deletion examples/pairgrid_dotplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

# Draw a dot plot using the stripplot function
g.map(sns.stripplot, size=10, orient="h",
palette="ch:s=1,r=-.1,h=1_r", linewidth=1, edgecolor="w")
palette="flare_r", linewidth=1, edgecolor="w")

# Use the same x axis limits on all columns and add better labels
g.set(xlim=(0, 25), xlabel="Crashes", ylabel="")
Expand Down
2 changes: 1 addition & 1 deletion examples/scatterplot_sizes.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Scatterplot with continuous hues and sizes
==========================================

_thumb: .45, .45
_thumb: .48, .45

"""
import seaborn as sns
Expand Down
39 changes: 39 additions & 0 deletions examples/timeseries_facets.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
"""
Small multiple time series
--------------------------

_thumb: .42, .58

"""
import seaborn as sns

sns.set(style="dark")
flights = sns.load_dataset("flights")

# Plot each year's time series in its own facet
g = sns.relplot(
data=flights,
x="month", y="passengers", col="year", hue="year",
kind="line", palette="crest", linewidth=4, zorder=5,
col_wrap=3, height=2, aspect=1.5, legend=False,
)

# Iterate over each subplot to customize further
for year, ax in g.axes_dict.items():

# Add the title as an annotation within the plot
ax.text(.8, .85, year, transform=ax.transAxes, fontweight="bold")

# Plot every year's time series in the background
sns.lineplot(
data=flights, x="month", y="passengers", units="year",
estimator=None, color=".7", linewidth=1, ax=ax,
)

# Reduce the frequency of the x axis ticks
ax.set_xticks(ax.get_xticks()[::2])

# Tweak the supporting aspects of the plot
g.set_titles("")
g.set_axis_labels("", "Passengers")
g.tight_layout()
11 changes: 1 addition & 10 deletions seaborn/_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
from .palettes import (
QUAL_PALETTES,
color_palette,
cubehelix_palette,
_parse_cubehelix_args,
)
from .utils import (
get_color_cycle,
Expand Down Expand Up @@ -236,15 +234,8 @@ def numeric_mapping(self, data, palette, norm):

if isinstance(palette, mpl.colors.Colormap):
cmap = palette
elif str(palette).startswith("ch:"):
args, kwargs = _parse_cubehelix_args(palette)
cmap = cubehelix_palette(0, *args, as_cmap=True, **kwargs)
else:
try:
cmap = mpl.cm.get_cmap(palette)
except (ValueError, TypeError):
err = f"Palette {palette} not understood"
raise ValueError(err)
cmap = color_palette(palette, as_cmap=True)

# Now sort out the data normalization
if norm is None:
Expand Down
Loading