Skip to content

Commit

Permalink
Update docs, tests, and release notes
Browse files Browse the repository at this point in the history
  • Loading branch information
mwaskom committed Aug 13, 2021
1 parent 47a1b9d commit d6f53a9
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 22 deletions.
2 changes: 1 addition & 1 deletion doc/docstrings/FacetGrid.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@
"source": [
"g = sns.FacetGrid(tips, col=\"sex\", row=\"time\", margin_titles=True, despine=False)\n",
"g.map_dataframe(sns.scatterplot, x=\"total_bill\", y=\"tip\")\n",
"g.fig.subplots_adjust(wspace=0, hspace=0)\n",
"g.figure.subplots_adjust(wspace=0, hspace=0)\n",
"for (row_val, col_val), ax in g.axes_dict.items():\n",
" if row_val == \"Lunch\" and col_val == \"Female\":\n",
" ax.set_facecolor(\".95\")\n",
Expand Down
2 changes: 1 addition & 1 deletion doc/introduction.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@
")\n",
"g.set_axis_labels(\"Bill length (mm)\", \"Bill depth (mm)\", labelpad=10)\n",
"g.legend.set_title(\"Body mass (g)\")\n",
"g.fig.set_size_inches(6.5, 4.5)\n",
"g.figure.set_size_inches(6.5, 4.5)\n",
"g.ax.margins(.15)\n",
"g.despine(trim=True)"
]
Expand Down
6 changes: 4 additions & 2 deletions doc/releases/v0.11.2.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ This is a minor release that addresses issues in the v0.11 series and adds a sma

- |Feature| In :func:`kdeplot`, added the `warn_singular` parameter to silence the warning about data with zero variance (:pr:`2566`).

- |Enhancement| In :class:`FacetGrid` and functions that use it, visibility of the interior axis labels is now disabled, and exterior axis labels are no longer erased when adding additional layers. This produces the same results for plots made by seaborn functions, but it may produce different (better, in most cases) results for customized facet plots (:pr:`2583`).

- |Enhancement| In :func:`histplot`, improved performance with large datasets and many groupings/facets (:pr:`2559`, :pr:`2570`).

- |Enhancement| The :class:`FacetGrid` and :class:`PairGrid` objects now reference the underlying matplotlib figure with a `.figure` attribute. The existing `.fig` attribute still exists but is discouraged and may eventually be deprecated. The effect is that you can now call `obj.figure` on the return value from any seaborn function (:pr:`2639`).

- |Enhancement| In :class:`FacetGrid` and functions that use it, visibility of the interior axis labels is now disabled, and exterior axis labels are no longer erased when adding additional layers. This produces the same results for plots made by seaborn functions, but it may produce different (better, in most cases) results for customized facet plots (:pr:`2583`).

- |Enhancement| In :class:`FacetGrid`, :class:`PairGrid`, and functions that use them, the matplotlib `figure.autolayout` parameter is disabled to avoid having the legend overlap the plot (:pr:`2571`).

- |Enhancement| The :func:`load_dataset` helper now produces a more informative error when fed a dataframe, easing a common beginner mistake (:pr:`2604`).
Expand Down
6 changes: 3 additions & 3 deletions doc/tutorial/axis_grids.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -245,14 +245,14 @@
"g.map(sns.scatterplot, \"total_bill\", \"tip\", color=\"#334488\")\n",
"g.set_axis_labels(\"Total bill (US Dollars)\", \"Tip\")\n",
"g.set(xticks=[10, 30, 50], yticks=[2, 6, 10])\n",
"g.fig.subplots_adjust(wspace=.02, hspace=.02)"
"g.figure.subplots_adjust(wspace=.02, hspace=.02)"
]
},
{
"cell_type": "raw",
"metadata": {},
"source": [
"For even more customization, you can work directly with the underling matplotlib ``Figure`` and ``Axes`` objects, which are stored as member attributes at ``fig`` and ``axes`` (a two-dimensional array), respectively. When making a figure without row or column faceting, you can also use the ``ax`` attribute to directly access the single axes."
"For even more customization, you can work directly with the underling matplotlib ``Figure`` and ``Axes`` objects, which are stored as member attributes at ``figure`` and ``axes_dict``, respectively. When making a figure without row or column faceting, you can also use the ``ax`` attribute to directly access the single axes."
]
},
{
Expand All @@ -263,7 +263,7 @@
"source": [
"g = sns.FacetGrid(tips, col=\"smoker\", margin_titles=True, height=4)\n",
"g.map(plt.scatter, \"total_bill\", \"tip\", color=\"#338844\", edgecolor=\"white\", s=50, lw=1)\n",
"for ax in g.axes.flat:\n",
"for ax in g.axes_dict.values():\n",
" ax.axline((0, 0), slope=.2, c=\".2\", ls=\"--\", zorder=0)\n",
"g.set(xlim=(0, 60), ylim=(0, 14))"
]
Expand Down
4 changes: 2 additions & 2 deletions doc/tutorial/relational.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@
"df = pd.DataFrame(dict(time=np.arange(500),\n",
" value=np.random.randn(500).cumsum()))\n",
"g = sns.relplot(x=\"time\", y=\"value\", kind=\"line\", data=df)\n",
"g.fig.autofmt_xdate()"
"g.figure.autofmt_xdate()"
]
},
{
Expand Down Expand Up @@ -519,7 +519,7 @@
"df = pd.DataFrame(dict(time=pd.date_range(\"2017-1-1\", periods=500),\n",
" value=np.random.randn(500).cumsum()))\n",
"g = sns.relplot(x=\"time\", y=\"value\", kind=\"line\", data=df)\n",
"g.fig.autofmt_xdate()"
"g.figure.autofmt_xdate()"
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion examples/joint_histogram.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
g.ax_joint.set(yscale="log")

# Create an inset legend for the histogram colorbar
cax = g.fig.add_axes([.15, .55, .02, .2])
cax = g.figure.add_axes([.15, .55, .02, .2])

# Add the joint and marginal histogram plots
g.plot_joint(
Expand Down
2 changes: 1 addition & 1 deletion examples/kde_ridgeplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def label(x, color, label):
g.map(label, "x")

# Set the subplots to overlap
g.fig.subplots_adjust(hspace=-.25)
g.figure.subplots_adjust(hspace=-.25)

# Remove axes details that don't play well with overlap
g.set_titles("")
Expand Down
22 changes: 11 additions & 11 deletions seaborn/tests/test_axisgrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,26 +190,26 @@ def test_axes_dict(self):
def test_figure_size(self):

g = ag.FacetGrid(self.df, row="a", col="b")
npt.assert_array_equal(g.fig.get_size_inches(), (6, 9))
npt.assert_array_equal(g.figure.get_size_inches(), (6, 9))

g = ag.FacetGrid(self.df, row="a", col="b", height=6)
npt.assert_array_equal(g.fig.get_size_inches(), (12, 18))
npt.assert_array_equal(g.figure.get_size_inches(), (12, 18))

g = ag.FacetGrid(self.df, col="c", height=4, aspect=.5)
npt.assert_array_equal(g.fig.get_size_inches(), (6, 4))
npt.assert_array_equal(g.figure.get_size_inches(), (6, 4))

def test_figure_size_with_legend(self):

g = ag.FacetGrid(self.df, col="a", hue="c", height=4, aspect=.5)
npt.assert_array_equal(g.fig.get_size_inches(), (6, 4))
npt.assert_array_equal(g.figure.get_size_inches(), (6, 4))
g.add_legend()
assert g.fig.get_size_inches()[0] > 6
assert g.figure.get_size_inches()[0] > 6

g = ag.FacetGrid(self.df, col="a", hue="c", height=4, aspect=.5,
legend_out=False)
npt.assert_array_equal(g.fig.get_size_inches(), (6, 4))
npt.assert_array_equal(g.figure.get_size_inches(), (6, 4))
g.add_legend()
npt.assert_array_equal(g.fig.get_size_inches(), (6, 4))
npt.assert_array_equal(g.figure.get_size_inches(), (6, 4))

def test_legend_data(self):

Expand Down Expand Up @@ -343,7 +343,7 @@ def test_gridspec_kws(self):
ax.set_xticks([])
ax.set_yticks([])

g.fig.tight_layout()
g.figure.tight_layout()

for (l, m, r) in g.axes:
assert l.get_position().width > m.get_position().width
Expand Down Expand Up @@ -758,10 +758,10 @@ def test_corner(self):
plot_vars = ["x", "y", "z"]
g = ag.PairGrid(self.df, vars=plot_vars, corner=True)
corner_size = sum([i + 1 for i in range(len(plot_vars))])
assert len(g.fig.axes) == corner_size
assert len(g.figure.axes) == corner_size

g.map_diag(plt.hist)
assert len(g.fig.axes) == (corner_size + len(plot_vars))
assert len(g.figure.axes) == (corner_size + len(plot_vars))

for ax in np.diag(g.axes):
assert not ax.yaxis.get_visible()
Expand All @@ -770,7 +770,7 @@ def test_corner(self):
plot_vars = ["x", "y", "z"]
g = ag.PairGrid(self.df, vars=plot_vars, corner=True)
g.map(scatterplot)
assert len(g.fig.axes) == corner_size
assert len(g.figure.axes) == corner_size

def test_size(self):

Expand Down

0 comments on commit d6f53a9

Please sign in to comment.