Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Simple line plots using seaborn

I'm trying to plot a ROC curve using seaborn (python). With matplotlib I simply use the function plot:

plt.plot(one_minus_specificity, sensitivity, 'bs--') 

where one_minus_specificity and sensitivity are two lists of paired values.

Is there a simple counterparts of the plot function in seaborn? I had a look at the gallery but I didn't find any straightforward method.

like image 379
Titus Pullo Avatar asked Jun 26 '15 09:06

Titus Pullo


People also ask

How do I make a line plot in Seaborn?

Using size parameter to plot multiple line plots in Seaborn. We can even use the size parameter of seaborn. lineplot() function to represent the multi data variable relationships with a varying size of line to be plotted. So it acts as a grouping variable with different size/width according to the magnitude of the data ...

How do you plot multiple lines in Seaborn?

You probably need to re-organize your dataframe in a suitable way so that there is one column for the x data, one for the y data, and one which holds the label for the data point. You can also just use matplotlib. pyplot . If you import seaborn , much of the improved design is also used for "regular" matplotlib plots.

How do you plot a Lineplot?

To plot a line plot in Matplotlib, you use the generic plot() function from the PyPlot instance. There's no specific lineplot() function - the generic one automatically plots using lines or markers. This results in much the same line plot as before, as the values of x are inferred.


1 Answers

Since seaborn also uses matplotlib to do its plotting you can easily combine the two. If you only want to adopt the styling of seaborn the set_style function should get you started:

import matplotlib.pyplot as plt import numpy as np import seaborn as sns  sns.set_style("darkgrid") plt.plot(np.cumsum(np.random.randn(1000,1))) plt.show() 

Result:

enter image description here

like image 97
hitzg Avatar answered Oct 16 '22 09:10

hitzg