Search code examples
pythonmatplotlibplotggplot2survival-analysis

Why are my python plots not styled like modern ggplots?


I've been following along with this tutorial, using my own data set. I can get the plots to show, but they don't look as nice as the ones in that website.

For comparison, here's one I'm getting:enter image description here

and here is one in their example:enter image description here

I had to add plt.show() to get my plot to show, so is this what's causing it? It seems like theirs is a ggplot and mine is off of matplotlib, so I'm guessing that's the root of the cause. However, I just can't get my plots to show without adding that line, so I'm not sure what to do. This will be for a report, so I'd really like to get the nicer looking plots.


Solution

  • Install seaborn, import it:

    import seaborn
    

    and do your plot again.

    Also, turn on the inline mode for matplotlib in the notebook:

    %matplotlib inline
    

    Alternatively use:

    %matplotlib notebook
    

    for zoomable plots.

    Plot before:

    enter image description here

    Plot after:

    enter image description here

    these steps.