python - Formatting style for matplotlib: scatterplot histogram hybrid
问题描述
In an old standalone plotting package (sm) there was a style available for scatter plots which I found more appealing to the general style. It appears as each point looking almost like a histogram which stretches to the next point.
An example of a scatter plot using this style:
Matplotlib does have this style for histograms, but I'm wondering if there's a way to cheat the system to allow the style to work for scatter plots.
解决方案
我认为一些混乱来自于所需的情节不是散点图这一事实。这是一个线图,线的形式为阶梯函数。
pyplot.step(x,y)
您可以用或绘制阶跃函数plot(x,y, drawstyle="steps")
。
import matplotlib.pyplot as plt
import numpy as np; np.random.seed(42)
x = np.linspace(0,1)
y = np.random.rand(len(x))
fig, ax = plt.subplots()
ax.step(x,y)
# or
# ax.plot(x,y, drawstyle="steps")
plt.show()
推荐阅读
- python - 在 Python 中使用 SOCKS 5 代理从 FTP 服务器下载文件
- reactjs - 如何在本机反应中从另一个更新组件
- vb.net - VSTO Outlook:AddToSelection(mailItem) 不起作用
- google-cloud-platform - Google 机器中的环境变量“GOOGLE_APPLICATION_CREDENTIALS”
- php - 通过url参数从数据库中获取值
- javascript - 有没有办法为每个对嵌入消息做出反应的用户编辑频道?
- java - Wildfly 服务器用于显示屏幕的 .class 或 .java
- php - 我已经在 github 上上传了 laravel 项目,但是在本地机器上下载它时会显示控制器的旧文件
- firefox - localstorage firefox中的配额超出
- amazon-web-services - AWS EC2 实例上的 LVM 镜像