Questions tagged «bar-chart»


9
如何使用pyplot.barh()在每个条形上显示条形的值?
我生成了条形图,如何在每个条形上显示条形的值? 当前情节: 我想要得到的是: 我的代码: import os import numpy as np import matplotlib.pyplot as plt x = [u'INFO', u'CUISINE', u'TYPE_OF_PLACE', u'DRINK', u'PLACE', u'MEAL_TIME', u'DISH', u'NEIGHBOURHOOD'] y = [160, 167, 137, 18, 120, 36, 155, 130] fig, ax = plt.subplots() width = 0.75 # the width of the bars ind = np.arange(len(y)) …


2
如何使用ggplot2在R中的每个条形图上在geom_bar上放置标签
我发现了如何使用ggplot2在R中的geom_bar上放置标签放置标签,但是它只是将label(numbers)放在一个栏中。 假设这是每个x轴的两个条形,该怎么做? 我的数据和代码如下所示: dat <- read.table(text = "sample Types Number sample1 A 3641 sample2 A 3119 sample1 B 15815 sample2 B 12334 sample1 C 2706 sample2 C 3147", header=TRUE) library(ggplot2) bar <- ggplot(data=dat, aes(x=Types, y=Number, fill=sample)) + geom_bar(position = 'dodge') + geom_text(aes(label=Number)) 然后,我们将获得: 似乎数字文本也位于“躲避”模式中。我搜索了geom_text手册以查找一些信息,但是无法使其正常工作。 有什么建议吗?
99 r  ggplot2  bar-chart 

8
旋转R中的x轴标签进行绘制
我正在尝试使x轴标签在没有运气的条形图中旋转45度。这是我下面的代码: barplot(((data1[,1] - average)/average) * 100, srt = 45, adj = 1, xpd = TRUE, names.arg = data1[,2], col = c("#3CA0D0"), main = "Best Lift Time to Vertical Drop Ratios of North American Resorts", ylab = "Normalized Difference", yaxt = 'n', cex.names = 0.65, cex.lab = 0.65)

1
将geom_text放在闪避的barplot上
我试图使标题变得不言自明,但是这里是-数据优先: dtf <- structure(list(variable = structure(c(1L, 1L, 2L, 2L, 3L, 3L, 4L, 4L, 5L, 5L), .Label = c("vma", "vla", "ia", "fma", "fla"), class = "factor"), ustanova = structure(c(1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L), .Label = c("srednja škola", "fakultet"), class = "factor"), `(all)` = c(42.9542857142857, 38.7803203661327, 37.8996138996139, …
96 r  plot  ggplot2  bar-chart 

4
R ggplot2:stat_count()不得与条形图中的美学错误一起使用
我在绘制条形图时遇到此错误,但我无法摆脱它,我尝试了qplot和ggplot,但仍然是相同的错误。 以下是我的代码: library(dplyr) library(ggplot2) #Investigate data further to build a machine learning model data_country = data %>% group_by(country) %>% summarise(conversion_rate = mean(converted)) #Ist method qplot(country, conversion_rate, data = data_country,geom = "bar", stat ="identity", fill = country) #2nd method ggplot(data_country)+aes(x=country,y = conversion_rate)+geom_bar() 错误: stat_count() must not be used with a y …
89 r  ggplot2  bar-chart 

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.