0

I am trying to plot several plots, here is the code:

import seaborn as sns
import matplotlib.pyplot as plt

fig, axes = plt.subplots(round(len(matching)/2), 2, figsize=(20, 25))
fig.subplots_adjust(hspace=2)

for i, col in enumerate(matching):
    # Method 1: on the same Axis
    ax = axes[i // 2, i % 2]
    sns.distplot(hcp_fs_by_hcp_new[col],ax=ax, kde_kws={"color":"r", "lw": 2, "label":"LA5"}, hist_kws={"label":"LA5","color": "r"})
    sns.distplot(hcp_fs_by_scoltech[col],ax=ax, kde_kws={"color":"g", "lw": 2, "label":"hcp"}, hist_kws={"label":"hcp"})
    ax.set_title(col)

plt.setp(axes, yticks=[])

plt.tight_layout()
plt.show()

and get the result where all plots are very tight and pressed, how to output them in fixed size, with scrolling?

how it looks now

sentence
  • 8,213
  • 4
  • 31
  • 40
  • 1
    A figure with scrollbar would be shown [here](https://stackoverflow.com/questions/42622146/scrollbar-on-matplotlib-showing-page/42624276#42624276). – ImportanceOfBeingErnest Jun 18 '19 at 12:38
  • ...or alternatively, as all subplots have different xy axes, maybe you could split them across multiple figures. – Leporello Jun 18 '19 at 14:47
  • @ImportanceOfBeingErnest maybe something could be simplified in my code, I think PyQt looks inconvenient – PatrickHellman Jun 18 '19 at 14:51
  • @Leporello any suggestions? how could it be implemented? – PatrickHellman Jun 18 '19 at 14:51
  • Because screens are usually wider than tall, would you maybe benefit from 3 columns of subplots? Else, I don't know what you mean by "simplified". – ImportanceOfBeingErnest Jun 18 '19 at 16:19
  • @ImportanceOfBeingErnest I mean, more clear implementation of visualization. – PatrickHellman Jun 18 '19 at 16:29
  • Maybe consider the fact that noone will look at each single plot of those anyways. So ask yourself: What is the important message I want to convey? Then think about how to visualize it. – ImportanceOfBeingErnest Jun 18 '19 at 17:23
  • @PatrickHellman for instance, initialize `list_of_figs = []` before the loop, put in your loop `if i % 2 == 0: fig, axes = plt.subplots(nrows=1, ncols=2)`, issue graphics calls in the loop to `ax[i % 2]` and tack a `list_of_figs.append(fig)` somewhere, and you can use `list_of_figs` for future `savefig` commands. Whether that method is better than IOBE's scrollable figure, and if so how many subplots per figure (in which grid pattern) is optimal, is something you need to decide by yourself. – Leporello Jun 18 '19 at 17:31
  • @ImportanceOfBeingErnest ok, no matter what will be number of subplots, I want them to save constant size – PatrickHellman Jun 18 '19 at 18:41
  • @Leporello didn't get the idea – PatrickHellman Jun 18 '19 at 18:41
  • Is this question about changing the size of a figure? That would be answered [here](https://stackoverflow.com/questions/332289/how-do-you-change-the-size-of-figures-drawn-with-matplotlib). (But if you change the question, please do so in the question, not in some comment to a comment, no one will ever read). – ImportanceOfBeingErnest Jun 18 '19 at 18:47

0 Answers0