How can I represent the classes on the histogram with colors?


Subhankar Nayak

I have a column in a dataset which I represent with a pyplot.hist graph. Use grey as a trash can. Another column by which I want to divide the graph is called "Class". There are two categories (0 and 1) in the Category column. I would like to represent class 0 data in grey and class 1 data in black. how to do this

Below is the plot formation I have tried

import matplotlib.pyplot as plt
x= subdf['V12']
y= subdf['Class']
plt.figure(figsize=(25,10))
plt.hist(x,bins=100,color='grey')
plt.show()

How can I modify it to show two different classes on the plot? Or can I easily implement my own motivation using other plots?

Rahul Verma
import seborn as sns
import matplotlib.pyplot as plt
fig=sns.FacetGrid(subdf,hue="Class",height=5,palette=["black", "grey"])
fig.map(sns.distplot,"V12")
fig.add_legend()
plt.show()

Related


How can I represent the classes on the histogram with colors?

Subhankar Nayak I have a column in a dataset which I represent with a pyplot.hist graph. Use grey as a trash can. Another column by which I want to divide the graph is called "Class". There are two categories (0 and 1) in the Category column. I would like to r

How can I represent the classes on the histogram with colors?

Subhankar Nayak I have a column in a dataset which I represent with a pyplot.hist graph. Use grey as a trash can. Another column by which I want to divide the graph is called "Class". There are two categories (0 and 1) in the Category column. I would like to r

How can I fix the histogram

aa I am trying to draw a very simple histogram using python. Here is my code: from numpy import * from matplotlib.pyplot import* from random import* nums = [] N = 10 for i in range(N): a = randint(0,10) nums.append(a) bars= [0,1,2,3,4,5,6,7,8,9] hist(

How can I fix the histogram

aa I am trying to draw a very simple histogram using python. Here is my code: from numpy import * from matplotlib.pyplot import* from random import* nums = [] N = 10 for i in range(N): a = randint(0,10) nums.append(a) bars= [0,1,2,3,4,5,6,7,8,9] hist(

How can I represent this response using Dataweave?

Shreejit Malshikhare I have an HTTP requester in my flow that calls the AmericanFlightsAPI and its raw GET response looks like this: [{ "ID": 1, "code": "ER38sd", "price": 400.00, "departureDate": "2016/03/20", "origin": "MUA", "destination": "SFO", "emptySeat

How can I represent hex numbers?

Mohanad Rafat I have an array of 4 hex elements and I want to represent the values as a hex number which is: int arr[4] = {0xD4, 0x9F, 0x2E, 0x4C}; int result = 0xD49F2E4C; //The total number I tried string concatenation but the result is not the same Ho

How can I represent hex numbers?

Mohanad Rafat I have an array of 4 hex elements and I want to represent the values as a hex number which is: int arr[4] = {0xD4, 0x9F, 0x2E, 0x4C}; int result = 0xD49F2E4C; //The total number I tried string concatenation but the result is not the same Ho

How can I represent this matrix in HTML code?

Mauro I have 2d matrix (mirrored) and it works as I expect. However, I don't know how to code the JavaScript properly so it doesn't create additional div elements. In the matrix I have (x,y) indices so it changes the correct position. However, new is added (ad

How can I represent a dataframe on my website?

Dave Warrior I'm using Flask to build a web application that allows users to upload datasets up to 100mb. I am using NumPy and Pandas for data processing. I need to be able to display the user dataframe - however, the dataframe itself will not be interactive.

How can I represent this response using Dataweave?

Shreejit Malshikhare I have an HTTP requester in my flow that calls the AmericanFlightsAPI and its raw GET response looks like this: [{ "ID": 1, "code": "ER38sd", "price": 400.00, "departureDate": "2016/03/20", "origin": "MUA", "destination": "SFO", "emptySeat

How can I represent a dataframe on my website?

Dave Warrior I'm using Flask to build a web application that allows users to upload datasets up to 100mb. I am using NumPy and Pandas for data processing. I need to be able to display the user dataframe - however, the dataframe itself will not be interactive.

How can I represent this matrix in HTML code?

Mauro I have 2d matrix (mirrored) and it works as I expect. However, I don't know how to code the JavaScript properly so it doesn't create additional div elements. In the matrix I have (x,y) indices so it changes the correct position. However, new is added (ad

How can I represent hex numbers?

Mohanad Rafat I have an array of 4 hex elements and I want to represent the values as a hex number which is: int arr[4] = {0xD4, 0x9F, 0x2E, 0x4C}; int result = 0xD49F2E4C; //The total number I tried string concatenation but the result is not the same Ho

How can I use an if statement to represent this situation?

Cookies Generate independent random variables XM ∼ Unif(−25,25) and YM ∼ Unif(−25,25), then if X^2M + Y^ 2 M ≤ 25^2 take (XM,YM) as the result, but if X ^2 M +Y ^2 M > 25^2 Try again — and keep trying until you accept the result. My question is how would I con

How can I represent this model in a table?

Matt I have a warehouse table and a customer table to manage several warehouses belonging to different customers warehouse ===== id address capacity owner_client client ===== id name My problem is that I have an ACME client and ACME's "ACME Security Level"

How can I represent this response using Dataweave?

Shreejit Malshikhare I have an HTTP requester in my flow that calls the AmericanFlightsAPI and its raw GET response looks like this: [{ "ID": 1, "code": "ER38sd", "price": 400.00, "departureDate": "2016/03/20", "origin": "MUA", "destination": "SFO", "emptySeat

How can I represent hex numbers?

Mohanad Rafat I have an array of 4 hex elements and I want to represent the values as a hex number which is: int arr[4] = {0xD4, 0x9F, 0x2E, 0x4C}; int result = 0xD49F2E4C; //The total number I tried string concatenation but the result is not the same Ho

How can I represent hex numbers?

Mohanad Rafat I have an array of 4 hex elements and I want to represent the values as a hex number which is: int arr[4] = {0xD4, 0x9F, 0x2E, 0x4C}; int result = 0xD49F2E4C; //The total number I tried string concatenation but the result is not the same Ho

How can I represent a dataframe on my website?

Dave Warrior I'm using Flask to build a web application that allows users to upload datasets up to 100mb. I am using NumPy and Pandas for data processing. I need to be able to display the user dataframe - however, the dataframe itself will not be interactive.

How can I represent this matrix in HTML code?

Mauro I have 2d matrix (mirrored) and it works as I expect. However, I don't know how to code the JavaScript properly so it doesn't create additional div elements. In the matrix I have (x,y) indices so it changes the correct position. However, new is added (ad

How can I represent this response using Dataweave?

Shreejit Malshikhare I have an HTTP requester in my flow that calls the AmericanFlightsAPI and its raw GET response looks like this: [{ "ID": 1, "code": "ER38sd", "price": 400.00, "departureDate": "2016/03/20", "origin": "MUA", "destination": "SFO", "emptySeat