mlxtend
mlxtend copied to clipboard
How to 2 plots side by side?
Can I plot 2 scatterplots with categories
side by side? For example, let's say I have made a scatter plot with following code from Example 1 - Category Scatter from Pandas DataFrames
import matplotlib.pyplot as plt
from mlxtend.plotting import category_scatter
fig = category_scatter(x='x', y='y', label_col='label',
data=df, legend_loc='upper left')
How can I plot the above one side by side with another scatterplots with categories
? I have tried using the code style below and it did not work...
fig, axes = plt.subplots(nrows=1,ncols=2,figsize=(18,7))
Unfortunately, I think you are right and this is currently not possible. The category_scatter
function is among the oldest ones in mlxtend, and the API is not ideal. To address the issue you have, we would need to add an option to accept the fig
and axes
as function parameters similar to the scatterplotmatrix
function:
- https://github.com/rasbt/mlxtend/blob/master/mlxtend/plotting/scatterplotmatrix.py