bar-chart

matplotlib bar plot add legend from categories dataframe column

。_饼干妹妹 提交于 2021-02-04 13:21:53
问题 I try to add the legend which should, according to my example, output: a red square with the word fruit and a green square with the word veggie. I tried several things (the example below is just 1 of the many trials), but I can't get it work. Can someone tell me how to solve this problem? import pandas as pd from matplotlib import pyplot as plt data = [['apple', 'fruit', 10], ['nanaba', 'fruit', 15], ['salat','veggie', 144]] data = pd.DataFrame(data, columns = ['Object', 'Type', 'Value'])

Iteration over years to plot different group values as bar plot in pandas

依然范特西╮ 提交于 2021-01-29 20:30:45
问题 I have a dataframe that records number of observations at different locations for different years. I am trying to make a barplot where I can show the total number of observations at different locations for different years. For each location, I want the total observations, for different years to be shown in different colors. My approach is to first make location groups and for each location group, calculate total observation. (I don't think I need to change the index to date - as I am grouping

Absolute Values and Percentage Values Side by Side in Bar Chart Matplotlib

女生的网名这么多〃 提交于 2021-01-29 15:16:01
问题 I would like to count on your help for the following problem that I have been facing. I've been trying, but without success, to put absolute values and percentage values side by side. Where 53 and 47 are percentage values and would be outside the parentheses and 17 and 15 are absolute values and would be inside the parentheses. Both absolute values and percentage values are already known, therefore, there is no need for any calculation to obtain them. I leave my code here for you to see how

simple bar plot with mithril.js and d3.js

折月煮酒 提交于 2021-01-29 08:47:07
问题 I am very very new to javascript and mithril.js. I am trying to create a very simple bar plot using mithril.js and d3.js. But, I am not having any luck even getting the axis in place. Firstly, I created a mithril "svg" component and appended a mithril "g" compent as follows: var g = m(gView, {transpose:"translate(10, 10)"}) var svg = m(SVGView, {width: 100, height:100}, g) where gView and SVGView are as follows: var gView = { view: function(vnode) { return m("g", vnode.attrs, [vnode.children]

How to break axis in a barplot (maybe using plotrix gap.barplot)?

霸气de小男生 提交于 2021-01-29 08:31:37
问题 I found a lot of SO question and answers addressing break and gaps in axis. But most of them are of low quality (in an SO meaning) because of no example code, no picture or to complex codes. This is why I asking. I try to use library(plotrix) . If there is a solution without it and/or another library it would be ok for me, too. This is a normal R-barplot. barplot(c(10,20,500)) To break the axis and add gap I tried this. gap.barplot(c(10,20,500),gap=c(50,400), col=FALSE) The result is not

Adding a legend to a combined line and bargraph ggplot

随声附和 提交于 2021-01-29 06:40:54
问题 So I know many people have asked similar questions but the code others have used does not seem to be working for my graph hence why I'm wondering if I have done something wrong. I have this code: ggplot(dfMonth) + geom_col(aes(x=Month, y=NumberMO), size=.7, colour="black", fill="white") + geom_line(aes(x=Month, y=NumberME), size=1, colour="black", group=1) + xlab("Month") + ylab("No. of birds observed") + theme_bw() + geom_point(x=Month, y=NumberME) + scale_colour_manual("" ,values =c(

how to modify axis labels ggplot in R

柔情痞子 提交于 2021-01-29 06:06:23
问题 I know there are other questions like this. However, this is a bit of two fold item. So, i am using the following code to arrange my horizontal bar chart in descending order by annual difference, A. First is the sample data and then making the data frame. A<- c(150,125,0,-300,-350,-370) Series<- c("Construction","Manufacturing","Information","Health_Care","Education","Government") testdf <- data.frame(A,Series) jobgrowth<-ggplot(data=testdf,mapping=aes(x=A,y=Series))+ geom_col(color="blue")

R: Adjust Color Gradient for 3DBarplot using latticeExtra cloud in R

久未见 提交于 2021-01-29 05:33:40
问题 I am trying to change the colors of the 3d bar plot so that the colors go from green, to yellow, to orange, to light red, to red, to dark red. However, whenever I plot it, it looks like the colors start repeating after green. Is there something, I can do to fix this? The output that I get is: The output that I want is this: enter image description here This is the code, I am using. It gives me the first picture. That is not what want. I want the colors to look the way they look in the second

How can a plot a 5 grouped bars bar chart in matplotlib?

☆樱花仙子☆ 提交于 2021-01-29 03:03:44
问题 I have the following dataframe: meteo = [["January", 9.2, 13.6, 4.7, 37, 70], ["February",9.9, 14.3, 5.4, 35, 70], ["March", 11.8, 16.1, 7.4, 36, 70], ["April", 13.7, 18.0, 9.4, 40, 69], ["May", 16.9, 21.1, 12.8, 47, 70], ["June", 20.9, 24.9, 16.8, 30, 68], ["July", 23.9, 28.0, 19.8, 21, 67], ["August", 24.4, 28.5, 20.2, 62, 68], ["September", 21.7, 26.0, 17.4, 81, 70], ["October", 17.8, 22.1, 13.5, 91, 73], ["November", 13.0, 17.3, 8.6, 59, 71], ["December", 10.0, 14.3, 5.7, 40, 69]] import

How can a plot a 5 grouped bars bar chart in matplotlib?

烂漫一生 提交于 2021-01-29 03:02:26
问题 I have the following dataframe: meteo = [["January", 9.2, 13.6, 4.7, 37, 70], ["February",9.9, 14.3, 5.4, 35, 70], ["March", 11.8, 16.1, 7.4, 36, 70], ["April", 13.7, 18.0, 9.4, 40, 69], ["May", 16.9, 21.1, 12.8, 47, 70], ["June", 20.9, 24.9, 16.8, 30, 68], ["July", 23.9, 28.0, 19.8, 21, 67], ["August", 24.4, 28.5, 20.2, 62, 68], ["September", 21.7, 26.0, 17.4, 81, 70], ["October", 17.8, 22.1, 13.5, 91, 73], ["November", 13.0, 17.3, 8.6, 59, 71], ["December", 10.0, 14.3, 5.7, 40, 69]] import