Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/71.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R 如何";“圆形”;ggplot中的范围线_R_Dataframe_Ggplot2_Graph_Time Series - Fatal编程技术网

R 如何";“圆形”;ggplot中的范围线

R 如何";“圆形”;ggplot中的范围线,r,dataframe,ggplot2,graph,time-series,R,Dataframe,Ggplot2,Graph,Time Series,我正在使用以下R代码为工作提出新的情节设计。如果我能把这幅图上红色条的末端画圆就好了。我想我应该在某个地方使用lineend=“round”,但我无法让它工作。(当前图附在下面) 库(ggplot2) #创建心率数据。 df2您是正确的,因为您需要使用lineend=“round”参数。正如您可能已经注意到的那样,这不是一个可用于geom\u linerange()的可接受参数。正如建议的那样,您可以使用geom_segment()绘制线范围,它可以接受lineend=参数 指示geom_段()

我正在使用以下R代码为工作提出新的情节设计。如果我能把这幅图上红色条的末端画圆就好了。我想我应该在某个地方使用lineend=“round”,但我无法让它工作。(当前图附在下面)

库(ggplot2)
#创建心率数据。

df2您是正确的,因为您需要使用
lineend=“round”
参数。正如您可能已经注意到的那样,这不是一个可用于
geom\u linerange()
的可接受参数。正如建议的那样,您可以使用
geom_segment()
绘制线范围,它可以接受
lineend=
参数

指示
geom_段()
将通过连接两个点来绘制线:
x
y
xend
yend
。对于垂直线范围,
x
xend
将是相同的,而
y
yend
将对应于
ymin
ymax
geom\u linerange()中使用的值

要获取圆线,请进行以下更改:

# substitute this:
# q + geom_linerange(aes(ymin = min, ymax = max, size = 4)) +

# with this:

q + geom_segment(
  aes(x=hour, xend=hour, y=min, yend=max),
  size=4, lineend='round'
  ) +


最后一点注意:我注意到你分享的图表有两个图例,一个是颜色,一个是大小。我猜您不希望
size
的图例出现在那里
ggplot2
当您在aes()中具有美学效果时,会创建一个图例。注意,在
geom_段()
中,我将
size=4
移动到
aes()之外。因此,没有创建尺寸图例。

我认为您可以使用
geom_segment()
并将
lineend
选项设置为“圆形”。如果你需要帮助,请告诉我。此处的正式文件:
# substitute this:
# q + geom_linerange(aes(ymin = min, ymax = max, size = 4)) +

# with this:

q + geom_segment(
  aes(x=hour, xend=hour, y=min, yend=max),
  size=4, lineend='round'
  ) +