I want to make a seaborn countplot()
. I don't have a dataframe, but I know what I want to graph.
I want to graph something like this
Where I can change the count/class/data values.
I know I need a dataframe but I don't have any data.
I really just need a way to manually graph this.
I have tried something like this, but I don't have a dataframe so it doesn't work:
data= sns.load_dataset("data")
ax = sns.countplot(x="class", data=data)
How could I make it so I can manually graph the data? Let's say I want to go from 0 to 3000 like in the picture, and have 5 Heartbeat classes on the bottom.
Is there any way I can manually do this? Maybe make a list with data and input it?-
CodePudding user response:
To create a seaborn graph without any data:
You can use a dataset that is already defined in seaborn
such as flight_data
There are many different ways you can graph the seaborn data.
Looking at the graph that you provided, you need to use seaborn.countplot()
Your code would look like this, where the data is stored in a list and is mutable.
import seaborn as sns
ax = sns.barplot(x=['Normal', 'R on T', 'PVC', 'SP', 'UB'], y=[2800, 1700, 200, 90, 30])
ax.set_ylabel('Count')
To style, add this:
%config InlineBackend.figure_format='retina'
sns.set(style='whitegrid', palette='muted', font_scale=1.2)
graphcolorpallet = ["#01BEFE", "#FFDD00", "#FF7D00", "#FF006D", "#ADFF02", "#8F00FF"]
sns.set_palette(sns.color_palette(graphcolorpallet))
rcParams['figure.figsize'] = 12, 8
This should give something like this as the result.
You can learn more about creating graphs with
Or you could create a countplot
with simulated data:
import seaborn as sns
values = ['Normal'] * 2800 ['R on T'] * 1700 ['PVC'] * 200 ['SP'] * 90 ['UB'] * 30
sns.countplot(x=values)