我能够使用
生成具有可变binwidth的条形图byA<-barplot(table(A),width=B$length, space = 0,col="black")
我如何使用ggplot做同样的事情?
我试过这个:
ggplot(data.frame(table(A)), aes(x=B$Start, y=Freq, width=B$length)) +
geom_bar(aes(fill=B$length), stat="identity", position="identity")
如何摆脱条形之间的空间并将它们的位置从0开始而不是以x标记为中心? (我猜这可能会让我得到同样的条形图。)注意:我更喜欢第二个图中的x轴值,所以很好。
这是我数据的前20行:
bin Freq
1 [0,0.78) 9
2 [0.78,0.99) 1
3 [0.99,1.07) 1
4 [1.07,1.201) 1
5 [1.201,1.211) 0
6 [1.211,1.77) 3
7 [1.77,1.95) 0
8 [1.95,2.14) 2
9 [2.14,2.15) 0
10 [2.15,2.581) 0
11 [2.581,3.04) 4
12 [3.04,3.11) 0
13 [3.11,3.22) 0
14 [3.22,3.33) 1
15 [3.33,3.58) 3
16 [3.58,4.18) 8
17 [4.18,4.29) 2
18 [4.29,4.48) 4
19 [4.48,4.62) 4
20 [4.62,4.8) 3
答案 0 :(得分:1)
通过在stat_bin
中使用# We'll use the diamonds data set within ggplot2 for an example
library(ggplot2)
# Set breaks for the bars. The bins are:
# 1st bin: [0, 100), centered at 50
# 2nd bin: [100, 500), centered at 300
# 3rd bin: [500, 1000),
# 4th bin: [1000, 2000),
# 5th bin: [2000, 5000),
# etc.
#
# to have (a, b] style intervals use the argument right = TRUE in the stat_bin
# call.
brks <- c(0, 100, 500, 1000, 2000, 5000, 7500, 10000, max(diamonds$price))
ggplot(diamonds, aes(x = price)) +
geom_bar() +
stat_bin(breaks = brks)
参数,您可以构建情节
正在寻找。
$postvars = '';
foreach($data as $key=>$value) {
$postvars .= $key . "=" . $value . "&";
}
rtrim($postvars , '&'); // remove last &
$url = $topuplink."".$accesstoken;
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_POST, count($data)); // count of total post fields
curl_setopt($ch, CURLOPT_POSTFIELDS, $postvars);
curl_setopt($ch,CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
print_r($response);
curl_close ($ch);