With the following code, I can use seaborn’s scatterplot to plot data with certain colors assigned to data values. How can I set the amount of colors that get used in this example? (e.g. if I want to have only two colors used or more than the 6 shown in the example) Answer Seaborn’s scatterplot has a legend= keyword, which
Tag: seaborn
How to assign different palettes to hue levels in a Seaborn barplot?
I’m using Seaborn to create bar plots in Python. I have a 2 (attention: divided vs focused) X 3 (solutions: 1,2,3) design. For divided, I want the bar colors to be darkred, darkgreen, darkblue. For focused, I want the bar colors to be red, green, blue. This code doesn’t work because the palette only applies to the hue parameter: This
Plotting a particular set of contour line at desired point or location
I want a contour plot showing contour levels corresponding to a particular set of x,y. I tried increasing the number of contour lines but it doesn’t give the contour line near the required point. I want to get a contour line to suppose around (0.1,0.1) but am not able to do so, I tried increasing the number of contours but
How can I enumerate and add margin_titles to each subplot in a seaborn lmplot facetgrid?
I have the following attached lmplot facetgrid To start with, I want to simplify the title of each subplot, to only have corpus = {corpus name}. I am generating these plots using the lmplot as per I want to use the facetgrid margin_title option to put the measure value on the right y-axis, but get lmplot() got an unexpected keyword
How to visualize categorical frequency difference
Data: Diabetes dataset found here: https://raw.githubusercontent.com/LahiruTjay/Machine-Learning-With-Python/master/datasets/diabetes.csv Objective: I want to examine how many people under the Age of 30 have diabetes, which is indicated by a 1 or 0 in the “Outcome” column of the dataset and plot it to see if there is a class imbalance (more of 1 or more of 2 or roughly equal?) Method: Filter my
Seaborn plot displot with hue and dual y-scale (twinx)
I am trying to plot the output from the predict of a ML model, there are the classes 1,0 for the Target, and the Score. Due the dataset is not balanced, there are few 1’s. When I plot a simple displot with the Target in the hue parameter, the plot is useless for describing the 1’s I want to change
Multiple boxplots based on conditions
I have a dataframe with two columns. The power column represents the power consumption of the system. And the component_status column divide the data in two, based when the component is OFF or ON. When the values are 153 is when the component is ON and when the values are 150 the component is OFF. The result that I am
How to create grouped and stacked bars
I have a very huge dataset with a lot of subsidiaries serving three customer groups in various countries, something like this (in reality there are much more subsidiaries and dates): I’d like to make an analysis per subsidiary by producing a stacked bar chart. To do this, I started by defining the x-axis to be the unique months and by
How to get rid of scientific notation on bar labels in matplotlib?
How could I format the bar labels to remove the scientific notation? Answer As already suggested by BigBen in the comment, you can pass fmt parameter to matplotlib.axes.Axes.bar_label; you can use %d for integers:
Finding areas of non-overlapping edges of two distributions
I am trying to find a way to calculate the overlapping (intersection) and non-overlapping areas of two distributions. Based on some posts (like this: FINDING AREA) I could figure out how to calculate the intersection of the two plots. But I had no luck finding the non-overlapping part. Given this example distributions: I wonder how I can calculate the areas