python - 为什么我的 xlabel、ylabel 和 title 在散点图后没有显示?
问题描述
我正在用 Python 设置一个过滤工具。我想根据其他数据绘制一些数据,但我的散点图遇到了问题。实际上,显示的是数据,而不是图形标题、x 轴标签或 y 轴标签。有人可以解释我的错误吗?先感谢您。
x_text = str(self.comboBox1.currentText())
y_text = str(self.comboBox2.currentText())
x_data = self.data.getData(x_text)
y_data = self.data.getData(y_text)
if x_data is not None and y_data is not None :
if x_text =="Cycles":
fig, ax = plt.subplots()
ax = plt.subplot(111, facecolor= "lightgrey")
for x,y in zip(x_data, y_data):
if isinstance(y, list):
ax.scatter([x]*len(y),y,marker = 'o',color="chocolate")
else:
ax.scatter(x,y,marker = 'o', color="teal")
ax.set_title("Before filtering")
#ax.set_xlabel(x_text)
#ax.set_ylabel(y_text)
ax.grid(True)
fig.text(0.03,0.5 ,y_text, va='center', rotation = 'vertical', fontsize=12) #va : vertical alignement
fig.text(0.5 ,0.03,x_text, ha='center', fontsize=12)
plt.show()
解决方案
推荐阅读
- python - 如果不连续,有效地添加行
- sockets - 如何使用套接字选择功能
- php - LARAVEL 刷新我的数据库后,我遇到了在我的路线中找不到参数的问题
- javascript - GAS,Bootstrap Web 表单在表格中搜索和显示数据,但它不显示链接或超链接以单击它们(来自电子表格)
- html - 我怎样才能让我的整个 div 周围有阴影?
- python - 在 django admin 中搜索模型
- python - 创建 For 循环以预测组中的下一个值 (Python)
- php - 奖励预算削减 (PHP)
- c++ - 为什么我们在给出模板类型时需要加上括号
- c# - Unity 编辑器脚本:如何创建自定义弹出窗口以选择特定类