How to make inline plots in Jupyter Notebook larger?

后端 未结 9 1580
慢半拍i
慢半拍i 2020-12-12 08:38

I have made my plots inline on my Ipython Notebook with \"%matplotlib inline.\"

Now, the plot appears. However, it is very small. Is there a way to ma

相关标签:
9条回答
  • 2020-12-12 09:09

    The question is about matplotlib, but for the sake of any R users that end up here given the language-agnostic title:

    If you're using an R kernel, just use:

    options(repr.plot.width=4, repr.plot.height=3)
    
    0 讨论(0)
  • 2020-12-12 09:12

    A small but important detail for adjusting figure size on a one-off basis (as several commenters above reported "this doesn't work for me"):

    You should do plt.figure(figsize=(,)) PRIOR to defining your actual plot. For example:

    This should correctly size the plot according to your specified figsize:

    values = [1,1,1,2,2,3]
    _ = plt.figure(figsize=(10,6))
    _ = plt.hist(values,bins=3)
    plt.show()
    

    Whereas this will show the plot with the default settings, seeming to "ignore" figsize:

    values = [1,1,1,2,2,3]
    _ = plt.hist(values,bins=3)
    _ = plt.figure(figsize=(10,6))
    plt.show()
    
    0 讨论(0)
  • 2020-12-12 09:21

    I have found that %matplotlib notebook works better for me than inline with Jupyter notebooks.

    Note that you may need to restart the kernel if you were using %matplotlib inline before.

    Update 2019: If you are running Jupyter Lab you might want to use %matplotlib widget

    0 讨论(0)
提交回复
热议问题