I want to plot the frequencies of a variable y by a variable x and to that effect I am using the seaborn.countplot() method. However I am getting an error message.
For a reproducible example see below:
surveys_species_by_plot_sample
plot_id taxa
0 1 Bird
1 1 Rabbit
2 1 Rodent
3 2 Bird
4 2 Rabbit
5 2 Reptile
6 2 Rodent
7 3 Bird
8 3 Rabbit
9 3 Rodent
The intent now is to plot the number of taxa (Birds, Rabbits etc) by plot_id. I am using the following command:
sn.countplot(x = "plot_id", y = "taxa", data = surveys_species_by_plot_sample,
palette = sn.color_palette(palette = ["SteelBlue" , "Salmon"], n_colors = 4))
I am getting the following error message:
TypeError: Cannot pass values for both `x` and `y`
I do not understand, since the documentation states that both x and y variables can be passed to the function:
Parameters: x, y, hue : names of variables in data or vector data, optional Inputs for plotting long-form data. See examples for interpretation.
data : DataFrame, array, or list of arrays, optional Dataset for plotting. If x and y are absent, this is interpreted as wide-form. Otherwise it is expected to be long-form.
Your advice will be appreciated.