用plot函数完成1、2题
时间: 2024-03-23 19:41:59 浏览: 13
好的,以下是使用plot函数绘制图形的代码:
1. 绘制党派与女性候选人比例的图形:
```
prop_female <- aggregate(Female ~ Party, data = belection, FUN = mean)
plot(prop_female$Party, prop_female$Female,
xlab = "Party", ylab = "Proportion of Female Candidates",
main = "Proportion of Female Candidates by Party",
ylim = c(0, 1), xlim = c(0, 8),
type = "h", lwd = 10, col = "pink")
```
2. 绘制地区与女性候选人比例的图形:
```
prop_female <- aggregate(Female ~ Region, data = belection, FUN = mean)
plot(prop_female$Region, prop_female$Female,
xlab = "Region", ylab = "Proportion of Female Candidates",
main = "Proportion of Female Candidates by Region",
ylim = c(0, 1), xlim = c(0, 13),
type = "h", lwd = 10, col = "lightblue")
```
这些代码将绘制带有水平线条的垂直条形图,其中线条的长度表示女性候选人的比例。
相关推荐
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![doc](https://img-home.csdnimg.cn/images/20210720083327.png)