r语言这个图大小改大一点 #test #wujun的包 # 构造示例数据 data <- tibble( name = c('Citizen', 'Work Permit', 'Permanent Resident'), y = c(73,17,3)) highchart() %>% hc_chart(type = "pie",backgroundColor='#ffffff') %>% hc_add_series(data = data, colorByPoint = TRUE, innerSize = '50%') %>% hc_tooltip(pointFormat = '{series.name}: <b>{point.percentage:.1f}%</b>') %>% hc_add_theme(hc_theme_flat()) %>% hc_legend( #图例标题 title = list(text = "图例"), #图例是否显示 enabled = TRUE, #图例布局位置 align = "right", verticalAlign = "top", #是否浮动:图例是否在图内 floating = TRUE, #垂直或水平摆放 layout = "vertical", #图例的相对位置 x = 0, y =0)%>% hc_plotOptions(pie = list( allowPointSelect = TRUE, cursor = 'pointer', dataLabels = list( enabled = T, format = '<b>{point.name}</b>: {point.percentage:.1f} %' ), showInLegend = T, startAngle = -90, # 圆环的开始角度 endAngle = 90, # 圆环的结束角度 center = c('50%', '50%') ))
时间: 2024-03-20 07:41:38 浏览: 77
你可以通过增加`hc_chart`中的`height`和`width`参数来调整图形大小。例如,将`height`和`width`都设置为500,代码如下:
```
library(highcharter)
library(tibble)
# 构造示例数据
data <- tibble(
name = c('Citizen', 'Work Permit', 'Permanent Resident'),
y = c(73,17,3)
)
highchart() %>%
hc_chart(type = "pie", backgroundColor='#ffffff', height = 500, width = 500) %>%
hc_add_series(data = data,
colorByPoint = TRUE,
innerSize = '50%') %>%
hc_tooltip(pointFormat = '{series.name}: <b>{point.percentage:.1f}%</b>') %>%
hc_add_theme(hc_theme_flat()) %>%
hc_legend(
#图例标题
title = list(text = "图例"),
#图例是否显示
enabled = TRUE,
#图例布局位置
align = "right", verticalAlign = "top",
#是否浮动:图例是否在图内
floating = TRUE,
#垂直或水平摆放
layout = "vertical",
#图例的相对位置
x = 0, y =0) %>%
hc_plotOptions(pie = list(
allowPointSelect = TRUE,
cursor = 'pointer',
dataLabels = list(
enabled = T,
format = '<b>{point.name}</b>: {point.percentage:.1f} %'
),
showInLegend = T,
startAngle = -90, # 圆环的开始角度
endAngle = 90, # 圆环的结束角度
center = c('50%', '50%')
))
```
你可以根据需要调整`height`和`width`的值。
阅读全文