我们如何将y轴更改为百分比,如图所示?我可以改变y轴范围,但我无法改变百分比.

我试图让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)
Run Code Online (Sandbox Code Playgroud) 我发现了这个,如何在带有ggplot2的R中将标签放在geom_bar上,但它只是将标签(数字)放在一个条上.
这就是说,每个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))
Run Code Online (Sandbox Code Playgroud)
然后,我们将得到:

似乎数字文本也定位在"闪避"模式中.我搜索了geom_text手册来查找一些信息,但无法使其正常工作.
建议?
我试图使标题不言自明,但这里 - 数据优先:
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,
33.7672811059908, 29.591439688716, 26.1890660592255, 27.9557692307692,
23.9426605504587, 33.2200772200772, 26.9493087557604)), .Names = c("variable",
"ustanova", "(all)"), row.names = c(NA, 10L), class = c("cast_df",
"data.frame"), idvars = c("variable", "ustanova"), rdimnames = list(
structure(list(variable …Run Code Online (Sandbox Code Playgroud) 我生成了条形图,如何在每个条形图上显示条形图的值?
目前情节:

我想要得到的:

我的代码:
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)) # the x locations for the groups
ax.barh(ind, y, width, color="blue")
ax.set_yticks(ind+width/2)
ax.set_yticklabels(x, minor=False)
plt.title('title')
plt.xlabel('x')
plt.ylabel('y')
#plt.show()
plt.savefig(os.path.join('test.png'), dpi=300, format='png', bbox_inches='tight') # use format='svg' or 'pdf' for vectorial pictures
Run Code Online (Sandbox Code Playgroud) 嗨伙计们,我在绘制条形图时遇到此错误,我无法摆脱它,我已经尝试了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()
Run Code Online (Sandbox Code Playgroud)
错误:
stat_count() must not be used with a y aesthetic
Run Code Online (Sandbox Code Playgroud)
data_country中的数据
country conversion_rate
<fctr> <dbl>
1 China 0.001331558
2 Germany 0.062428188
3 UK 0.052612025
4 US 0.037800687
Run Code Online (Sandbox Code Playgroud)
错误来自条形图而不是虚线图表.任何建议都会有很大帮助
假设我的条形图如下:

关于如何为每个载体设置不同颜色的任何想法?例如,AK是Red,GA是Green等等?
我在Python中使用Pandas和matplotlib
>>> f=plt.figure()
>>> ax=f.add_subplot(1,1,1)
>>> ax.bar([1,2,3,4], [1,2,3,4])
<Container object of 4 artists>
>>> ax.get_children()
[<matplotlib.axis.XAxis object at 0x6529850>, <matplotlib.axis.YAxis object at 0x78460d0>, <matplotlib.patches.Rectangle object at 0x733cc50>, <matplotlib.patches.Rectangle object at 0x733cdd0>, <matplotlib.patches.Rectangle object at 0x777f290>, <matplotlib.patches.Rectangle object at 0x777f710>, <matplotlib.text.Text object at 0x7836450>, <matplotlib.patches.Rectangle object at 0x7836390>, <matplotlib.spines.Spine object at 0x6529950>, <matplotlib.spines.Spine object at 0x69aef50>, <matplotlib.spines.Spine object at 0x69ae310>, <matplotlib.spines.Spine object at 0x69aea50>]
>>> ax.get_children()[2].set_color('r') #You can also try to locate the first patches.Rectangle object instead of direct …Run Code Online (Sandbox Code Playgroud) 我正在使用matplotlib生成(垂直)条形图.问题是我的标签很长.有没有办法在栏中或上方或下方垂直显示它们?
我正在绘制条形图 highchart.js
我不想显示x轴数据值.
谁能告诉我哪个选项呢?
完整配置:
var chart = new Highcharts.Chart({
chart: {
renderTo: container,
defaultSeriesType: 'bar'
},
title: {
text: null
},
subtitle: {
text: null
},
xAxis: {
categories: [''],
title: {
text: null
},
labels: {enabled:true,y : 20, rotation: -45, align: 'right' }
},
yAxis: {
min: 0,
gridLineWidth: 0,
title: {
text: '',
align: 'high'
}
},
tooltip: {
formatter: function () {
return '';
}
},
plotOptions: {
bar: {
dataLabels: {
enabled: true
},
pointWidth: …Run Code Online (Sandbox Code Playgroud) bar-chart ×10
r ×5
ggplot2 ×4
charts ×3
matplotlib ×3
plot ×3
python ×3
graph ×2
axis-labels ×1
gnuplot ×1
highcharts ×1
javascript ×1
jquery ×1
pandas ×1