简体   繁体   English

如何使用Python matplotlib绘制带有4个象限的图形或图形?

[英]How can I draw a graph or plot with 4 quadrants using Python matplotlib?

My objective is to draw a graph with 4 quadrants and plot points in the same. 我的目标是绘制一个带有4个象限和绘图点的图表。 And also, how can I divide a quadrant into several sectors? 而且,我如何将象限划分为几个扇区? How can I do the same in matplotlib: a graph/plot with 4 quadrants. 我怎样才能在matplotlib中做同样的事情:带有4个象限的图形/图形。 With x axis (1-9) and y-axis(1-9)? 使用x轴(1-9)和y轴(1-9)?

From the question, it sounds like you want a single graph with several delineated regions with a specific xy range. 从这个问题来看,听起来你想要一个带有几个具有特定xy范围的描绘区域的图形。 This is pretty straightforward to do. 这非常简单。 You can always just draw lines on the plot to delineate the regions of interest. 您可以随时在绘图上绘制线条以描绘感兴趣的区域。 Here is a quick example based on your stated objectives: 以下是基于您所述目标的简单示例:

import matplotlib.pyplot as plt

plt.figure()
# Hold activation for multiple lines on same graph
plt.hold('on')
# Set x-axis range
plt.xlim((1,9))
# Set y-axis range
plt.ylim((1,9))
# Draw lines to split quadrants
plt.plot([5,5],[1,9], linewidth=4, color='red' )
plt.plot([1,9],[5,5], linewidth=4, color='red' )
plt.title('Quadrant plot')
# Draw some sub-regions in upper left quadrant
plt.plot([3,3],[5,9], linewidth=2, color='blue')
plt.plot([1,5],[7,7], linewidth=2, color='blue')
plt.show()

I would take a look at the AxesGrid toolkit: 我将看一下AxesGrid工具包:

http://matplotlib.sourceforge.net/mpl_toolkits/axes_grid/index.html http://matplotlib.sourceforge.net/mpl_toolkits/axes_grid/index.html

Perhaps the middle image at the top of this page is something along the lines of what you are looking for. 也许本页顶部的中间图像与您正在寻找的内容类似。 There are examples on the following page in the API documentation that should be a good starting point: API文档中的以下页面上的示例应该是一个很好的起点:

http://matplotlib.sourceforge.net/mpl_toolkits/axes_grid/users/overview.html http://matplotlib.sourceforge.net/mpl_toolkits/axes_grid/users/overview.html

Without an example of what you want to do exactly it is difficult to give you the best advice. 如果没有您想要做的事情的例子,很难给您最好的建议。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM