-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update Heatscatter Docs and add example
- Loading branch information
1 parent
ab6eb6a
commit fbabd59
Showing
7 changed files
with
81 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import pandas as pd | ||
import numpy as np | ||
import matplotlib.pyplot as plt | ||
from pyrolite.plot import pyroplot | ||
|
||
# %% Minimal Example ------------------------------------------------------------------- | ||
# create some example data | ||
from pyrolite.util.synthetic import test_df, random_cov_matrix | ||
|
||
df = test_df( | ||
index_length=1000, | ||
cov=random_cov_matrix(sigmas=np.random.rand(4) * 2, dim=4, seed=12), | ||
seed=12, | ||
) | ||
|
||
fig, ax = plt.subplots(1, 3, sharex=True, sharey=True, figsize=(12, 4)) | ||
|
||
df.loc[:, ["SiO2", "MgO"]].pyroplot.scatter(ax=ax[0], c="k", s=10, alpha=0.3) | ||
df.loc[:, ["SiO2", "MgO"]].pyroplot.density(ax=ax[1]) | ||
df.loc[:, ["SiO2", "MgO"]].pyroplot.heatscatter(ax=ax[2], s=10, alpha=0.3) | ||
# %% Save Figure | ||
from pyrolite.util.plot import save_figure | ||
|
||
for t, a in zip(["Scatter", "Density", "Heatscatter"], ax): | ||
a.set_title(t) | ||
save_figure(fig, save_at="../../source/_static", name="heatscatter_compare") | ||
|
||
# %% Density Ternary ------------------------------------------------------------------- | ||
fig, ax = plt.subplots(1, 3, sharex=True, sharey=True, figsize=(14, 5)) | ||
|
||
df.loc[:, ["SiO2", "CaO", "MgO"]].pyroplot.scatter(ax=ax[0], c="k", s=10, alpha=0.1) | ||
df.loc[:, ["SiO2", "CaO", "MgO"]].pyroplot.density(ax=ax[1], bins=100) | ||
df.loc[:, ["SiO2", "CaO", "MgO"]].pyroplot.heatscatter(ax=ax[2], s=5, alpha=0.3) | ||
# %% Save Figure | ||
save_figure(fig, save_at="../../source/_static", name="heatscatter_ternary") |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
Heatscatter Plots | ||
================================== | ||
|
||
While :func:`~pyrolite.plot.pyroplot.density` plots are useful summary visualizations | ||
for large datasets, scatterplots are more precise and retain all spatial information | ||
(although they can get crowded). | ||
|
||
A scatter plot where individual points are coloured by data density in some respects | ||
represents the best of both worlds. A version inspired by similar existing | ||
visualisations is implemented with :func:`~pyrolite.plot.pyroplot.heatscatter`. | ||
|
||
.. literalinclude:: ../../../../examples/plotting/heatscatter.py | ||
:language: python | ||
:end-before: # %% Minimal Example | ||
|
||
We can compare a minimal :func:`~pyrolite.plot.pyroplot.heatscatter` plot to other | ||
visualisations for the same data: | ||
|
||
.. literalinclude:: ../../../../examples/plotting/heatscatter.py | ||
:language: python | ||
:start-after: # %% Minimal Example | ||
:end-before: # %% Save Figure | ||
|
||
.. image:: ../../../_static/heatscatter_compare.png | ||
:width: 100% | ||
:align: center | ||
:alt: Comparison of bivariate scatter plots, density plots and heatscatter plots. | ||
|
||
We can use the same interface for ternary diagrams: | ||
|
||
.. literalinclude:: ../../../../examples/plotting/heatscatter.py | ||
:language: python | ||
:start-after: # %% Density Ternary | ||
:end-before: # %% Save Figure | ||
|
||
.. image:: ../../../_static/heatscatter_ternary.png | ||
:width: 100% | ||
:align: center | ||
:alt: Comparison of ternary scatter plots, density plots and heatscatter plots. | ||
|
||
.. seealso:: `Ternary Plots <../plotting/ternary.html>`__, | ||
`Density Plots <../plotting/density.html>`__, | ||
`Spider Density Diagrams <conditionaldensity.html>`__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters