用matplotlib映射加号 [英] Mapping a plus symbol with matplotlib

查看:31
本文介绍了用matplotlib映射加号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用 mapplotlib 绘制一个加号,看起来像这样:

I want to use mapplotlib to graph a plus symbol that looks like this:

   _
 _| |_
|_   _|
  |_|

我一直在阅读matplotlib文档,但是坦率地说,我什至不知道要搜索什么来解决我的问题.实际上,我想在同一个 X 轴(即一条垂直线)上有两个点,但我似乎无法弄清楚如何做到这一点.理想情况下,我希望使用一组绘图点进行此操作,尽管我知道这是不可能的.

I've been reading through the matplotlib docs but, frankly, I'm not even sure what to search to fix my problem. Effectively I want to have two points on the same X axis (I.E. a vertical line) but I can't seem to figure out how to do this. Ideally I'd like to do this with one set of plot points, though I understand if this isn't possible.

如果我能以任何方式澄清我的问题,请告诉我.

Please let me know if I can clarify my problem in any way.

推荐答案

  1. 在方格纸上画出你想要的图形,
  2. 写下角的x,y值,
  3. 以相同的顺序将这些值放入一对列表(一个用于x,一个用于y)
  4. 绘制它.

例如:

>>> import matplotlib.pyplot as plt
>>> fig, ax = plt.subplots()
>>> y =[10, 20, 20, 30, 30, 40, 40, 30, 30, 20, 20, 10, 10]
>>> x =[10, 10, 0, 0, 10, 10, 20, 20, 30, 30, 20, 20, 10]
>>> line, = ax.plot(x, y, 'go-')
>>> ax.grid()
>>> ax.axis('equal')
(0.0, 30.0, 10.0, 40.0)
>>> plt.show()

产生:

这篇关于用matplotlib映射加号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆