matplotlib空心圆点
时间: 2023-09-10 19:06:29 浏览: 170
要绘制空心圆点,你可以使用matplotlib库中的plot函数或scatter函数,并设置marker参数为'o'。然后通过设置markeredgecolor参数来控制边颜色,将markerfacecolor参数设置为透明色(0, 0, 0, 0)来实现空心圆点效果。下面是一个使用plot函数和scatter函数绘制空心圆点的示例代码:
使用plot函数绘制空心圆点的示例代码:
``` python
import matplotlib.pyplot as plt
X = [1,2,3,4,5,6,7,8,9]
Y = [1,4,8,16,25,36,49,64,81]
plt.plot(X, Y, marker='o', markeredgecolor='red', markerfacecolor='none', label="空心圆点")
plt.xlabel("X")
plt.ylabel("Y")
plt.legend()
plt.show()
```
使用scatter函数绘制空心圆点的示例代码:
``` python
import matplotlib.pyplot as plt
import numpy as np
X = [1, 2, 3, 4, 5, 6, 7, 8, 9]
Y = [1, 4, 8, 16, 25, 36, 49, 64, 81]
plt.scatter(X, Y, facecolors='none', edgecolors='red', marker='o', label="空心圆点")
plt.xlabel("X")
plt.ylabel("Y")
plt.legend()
plt.show()
```
以上代码中,我们使用了plot函数和scatter函数来绘制空心圆点。在两种方法中,设置marker参数为'o'来指定点的样式为圆点,然后通过设置markeredgecolor参数为红色来控制圆点的边颜色,通过设置markerfacecolor参数为'none'或facecolors参数为'none'来设置圆点的内部颜色为透明色,从而实现空心圆点的效果。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [Python plt.plot绘制空心圆散点图](https://blog.csdn.net/weixin_40751444/article/details/129122730)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"]
- *2* [Python matplotlib通过plt.scatter画空心圆标记出特定的点方法](https://download.csdn.net/download/weixin_38653687/13764143)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"]
- *3* [matplotlib折线图上的点画成空心圆](https://blog.csdn.net/weixin_45284801/article/details/114592812)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"]
[ .reference_list ]
阅读全文