Closed ngreenwald closed 9 months ago
For anyone who's interested, here's what I did to get seaborn integrated. I just switched the Figure(1)
syntax in the example to fig, ax = plt.subplots()
, and it worked without any additional modifications.
# testing pylustrator
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
import numpy as np
import seaborn as sns
import pandas as pd
# now import pylustrator
import pylustrator
# activate pylustrator
pylustrator.start()
# build plots as you normally would
np.random.seed(1)
t = np.arange(0.0, 2, 0.001)
y = 2 * np.sin(np.pi * t)
a, b = np.random.normal(loc=(5., 3.), scale=(2., 4.), size=(100,2)).T
b += a
fig, ax = plt.subplots(1, 3)
ax[0].plot(t, y)
ax[2].plot(a, b, "o")
# add seaborn plot
plot_df = pd.DataFrame({'class': ['a', 'a', 'a', 'b', 'b', 'b'], 'value': [1, 2, 3, 4, 5, 6]})
sns.boxplot(data=plot_df, x='class', y='value', ax=ax[1])
# show the plot in a pylustrator window
plt.show()
Hi, I've recently started using your package, and it's super useful! I'm wondering if there's a way to combine seaborn plots with matplotlib plots? I followed the readme, but swapping in a seaborn plotting call for one of the example plots didn't seem to work. I know in general for combining seaborn plots with base matplotlib, the best way to go is by directly referencing the
ax
created withfig, ax = plt.subplots()
. Is there an equivalent modification that would work here?