histogram

R - hist plot colours by quantile

浪尽此生 提交于 2021-01-27 19:49:15
问题 I am trying to do a simple hist plot and colour the bins by quantile . I was wondering why when the bins size change the colours gets all messed up. Maybe I am not doing it right from the beginning. The quantiles are quantile(x) 0% 25% 50% 75% 100% 0.00 33.75 58.00 78.25 123.00 Then I am setting the colours with the quantile values k = ifelse(test = x <= 34, yes = "#8DD3C7", no = ifelse(test = (x > 34 & x <= 58), yes = "#FFFFB3", no = ifelse(test = (x > 58 & x <= 79), yes = "#BEBADA", no =

Gnuplot Polar Coodinates Histogram

耗尽温柔 提交于 2021-01-27 18:15:02
问题 I have a data file file.dat with three columns (radio, angle, Temperature) for points in the plane, and I want to plot this data as a histogram using polar coordenates and color maps, like in the figure below but using gnuplot. I can create a histogram.dat file with the values of the bins that I want but I don't know how to plot it in gnuplot 回答1: To my knowledge there is no right-away "polar heatmap" plotting style in gnuplot (but I could be wrong, at least, I haven't seen an example on the

Change colour of specific histogram bins in R

只谈情不闲聊 提交于 2021-01-24 08:26:46
问题 I have created the below historgram using the plot function: hist(mst$Total[which(mst$Total<100)], axes = TRUE, ylab = "", xlab = "", main = "", col = "chartreuse4", breaks = tb, freq=TRUE, right = FALSE) The breaks have been specified as the following: tb = c(0,1,5,10,15,20,25,30,35,40,45,50,55,60,65,70,75,80,85,90,95,100) I would like to be able to fill specific historgram bins with different colours. colour one: [0,1) colour two: [1,5) colour three: [5,10) [10,15) and [15,20) colour four:

How can i control bin intervals in ggplot2?

陌路散爱 提交于 2021-01-23 07:51:26
问题 I cant correctly control if a bin is going from e.g. -10 to +10 or from 0 to 20 when I say binwidth = 20 i get the former but I have data that begins at 1 and I dont want the interval to go into the negatives. Here is an example of my problem: testData = data.frame(x=c(1,4,6,9,9)) ggplot(data=testData, aes(x=testData$x)) + geom_histogram(binwidth=3, aes(col=I("white"))) + scale_x_continuous(breaks=c(1,2,3,4,5,6,7,8,9,10)) strange enough, if I use binwidth = 2 I end up with intervals like I

How to fill color by groups in histogram using Matplotlib?

孤者浪人 提交于 2021-01-18 07:15:00
问题 I know how to do this in R and have provided a code for it below. I want to know how can I do something similar to the below mentioned in Python Matplotlib or using any other library library(ggplot2) ggplot(dia[1:768,], aes(x = Glucose, fill = Outcome)) + geom_bar() + ggtitle("Glucose") + xlab("Glucose") + ylab("Total Count") + labs(fill = "Outcome") 回答1: Please consider the following example, which uses seaborn 0.11.1. import pandas as pd import numpy as np import seaborn as sns import

How to fill color by groups in histogram using Matplotlib?

北城余情 提交于 2021-01-18 07:06:30
问题 I know how to do this in R and have provided a code for it below. I want to know how can I do something similar to the below mentioned in Python Matplotlib or using any other library library(ggplot2) ggplot(dia[1:768,], aes(x = Glucose, fill = Outcome)) + geom_bar() + ggtitle("Glucose") + xlab("Glucose") + ylab("Total Count") + labs(fill = "Outcome") 回答1: Please consider the following example, which uses seaborn 0.11.1. import pandas as pd import numpy as np import seaborn as sns import

How to use R base plot to create a stacked histogram as barcode plot with row-wise color pattern from a R base table

孤者浪人 提交于 2021-01-07 03:57:17
问题 I came across a neat feature when plotting a table with base::plot() > test.matrix<-matrix(c(70,120,65,140,13,68,46,294,52,410),ncol=2,byrow=TRUE) > rownames(test.matrix)<-c("BC.1","BC.2","GC","MO","EB") > colnames(test.matrix)<-c("12m","3m") > test.matrix <- as.table(test.matrix) > test.matrix 12m 3m BC.1 70 120 BC.2 65 140 GC 13 68 MO 46 294 EB 52 410 > plot(test.matrix) This plots sth like a barcode plot, with bar height reflecting row-wise difference and bar width reflecting table cell

How to use R base plot to create a stacked histogram as barcode plot with row-wise color pattern from a R base table

给你一囗甜甜゛ 提交于 2021-01-07 03:54:30
问题 I came across a neat feature when plotting a table with base::plot() > test.matrix<-matrix(c(70,120,65,140,13,68,46,294,52,410),ncol=2,byrow=TRUE) > rownames(test.matrix)<-c("BC.1","BC.2","GC","MO","EB") > colnames(test.matrix)<-c("12m","3m") > test.matrix <- as.table(test.matrix) > test.matrix 12m 3m BC.1 70 120 BC.2 65 140 GC 13 68 MO 46 294 EB 52 410 > plot(test.matrix) This plots sth like a barcode plot, with bar height reflecting row-wise difference and bar width reflecting table cell

Add a normal distribution to seaborn 2D histogram

爱⌒轻易说出口 提交于 2021-01-07 01:24:01
问题 Is it possible to take a histogram from seaborn and add a normal distribution? Say I had something like this scatter plot and histogram from the documentation. import seaborn as sns penguins = sns.load_dataset("penguins") sns.jointplot(data=penguins, x="bill_length_mm", y="bill_depth_mm"); plt.savefig('deletethis.png', bbox_inches='tight') Can i superimpose a distribution on the sides like the image below? import matplotlib.pyplot as plt import numpy as np from scipy.stats import norm x = np

Histogram animation in Python

十年热恋 提交于 2021-01-03 06:40:19
问题 I am trying to make a histogram using animation, but it is not showing. #using animation library %matplotlib notebook import pandas as pd import numpy as np import matplotlib.animation as animation import matplotlib.pyplot as plt n=100 x=np.random.randn(n) def update(curr): if curr==n: a.event_source.stop() plt.cla() bins=np.arange(-4,4,0.5) plt.hist(x[:curr],bins=bins) plt.axis([-4,4,0,30]) plt.gca().set_title('sampling the normal distribution') plt.gca.set_ylabel('frequency') plt.gca().set