0

I have several matplotlib figure objects organised in a pandas dataframe. I am looking for a way to display such a dataframe within a jupyter notebook.

To give an example for such a dataframe:

import pandas as pd
import matplotlib.pyplot as plt
pdf = pd.DataFrame({'a':{'a1': plt.Figure(), 'a2': plt.Figure()}, 
                    'b': {'a1': plt.Figure(), 'a2': plt.Figure()}}

Currently, I am thinking of creating an html template of the table, pasting in the figures in png format. But maybe there is a more elegant way? Maybe it is already implemented?

Sidenote: I am aware, that the usual way of combining several plots is to use several axes within one figure object, but that is not what I am asking for.

Arco Bast
  • 3,595
  • 2
  • 26
  • 53
  • This requirement is indeed quite unusual. If you can create a html representation for such dataframe yourself, that would be the best option I suppose. May I ask why using subplots on a matplotlib figure is not an option? – ImportanceOfBeingErnest Jul 11 '18 at 11:42
  • @ImportanceOfBeingErnest I have a dataframe showing me some performance measures about a set of classifiers. I want to add some properties that are best visualized graphically. So I thought the most convenient way would be to simply add a column to the dataframe containing fig objects. – Arco Bast Jul 11 '18 at 12:47
  • So the idea is to have some other text-like content in the dataframe as well?! In that case I suppose my answer to [this question](https://stackoverflow.com/questions/47038538/insert-matplotlib-images-into-a-pandas-dataframe) would solve your problem? – ImportanceOfBeingErnest Jul 11 '18 at 12:50
  • Exactly, that was my intention. Great, your answer is exactly, what I was looking for! Thanks – Arco Bast Jul 11 '18 at 12:52
  • So I would say, this is a duplicate? Sorry, I did not find your answer before. – Arco Bast Jul 11 '18 at 12:53
  • 1
    I did close as duplicate, yes. In case you have a problem with the provided solution or are looking for an alternative, it would be best to ask a new question with more details on the exact problem. Good luck with your project. – ImportanceOfBeingErnest Jul 11 '18 at 12:56

0 Answers0