Scatter plots¶
In [1]:
Copied!
import matplotlib.pyplot as plt
import plotly.express as px
import arcadia_pycolor as apc
apc.mpl.setup()
apc.plotly.setup()
df = px.data.iris()
import matplotlib.pyplot as plt
import plotly.express as px
import arcadia_pycolor as apc
apc.mpl.setup()
apc.plotly.setup()
df = px.data.iris()
1. Scatter plot with Matplotlib¶
In [2]:
Copied!
fig, ax = plt.subplots(figsize=apc.mpl.get_figure_dimensions("float_wide"), layout="constrained")
scatter = ax.scatter(
x=df["sepal_width"],
y=df["sepal_length"],
c=df["petal_length"],
cmap="apc:magma",
)
ax.set_xlabel("Sepal width")
ax.set_ylabel("Sepal length")
cb = fig.colorbar(scatter, ax=ax)
cb.set_label("Petal length")
cb.outline.set_visible(False) # type: ignore
apc.mpl.style_plot(monospaced_axes="all", colorbar_exists=True)
plt.show()
fig, ax = plt.subplots(figsize=apc.mpl.get_figure_dimensions("float_wide"), layout="constrained")
scatter = ax.scatter(
x=df["sepal_width"],
y=df["sepal_length"],
c=df["petal_length"],
cmap="apc:magma",
)
ax.set_xlabel("Sepal width")
ax.set_ylabel("Sepal length")
cb = fig.colorbar(scatter, ax=ax)
cb.set_label("Petal length")
cb.outline.set_visible(False) # type: ignore
apc.mpl.style_plot(monospaced_axes="all", colorbar_exists=True)
plt.show()
2. Scatter plot with Plotly¶
In [3]:
Copied!
fig = px.scatter(
df,
x="sepal_width",
y="sepal_length",
color="petal_length",
color_continuous_scale=apc.gradients.magma.to_plotly_colorscale(),
)
apc.plotly.style_plot(fig, monospaced_axes="all")
apc.plotly.set_figure_dimensions(fig, "float_wide")
fig.show()
fig = px.scatter(
df,
x="sepal_width",
y="sepal_length",
color="petal_length",
color_continuous_scale=apc.gradients.magma.to_plotly_colorscale(),
)
apc.plotly.style_plot(fig, monospaced_axes="all")
apc.plotly.set_figure_dimensions(fig, "float_wide")
fig.show()