3

My objective is to draw a graph with 4 quadrants and plot points in the same. 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. With x axis (1-9) and y-axis(1-9)?

Jakub Hampl
  • 39,863
  • 10
  • 77
  • 106
siddarthforever
  • 75
  • 1
  • 1
  • 7
  • 3
    Answers here are not too useful. Check [this one](https://stackoverflow.com/a/52750804/4124317) and the [link to the documentation](https://matplotlib.org/gallery/ticks_and_spines/spine_placement_demo.html) instead. – ImportanceOfBeingErnest Sep 08 '19 at 13:57

3 Answers3

4

From the question, it sounds like you want a single graph with several delineated regions with a specific xy range. 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()
# 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()

Quadrant Plot

T3am5hark
  • 856
  • 6
  • 9
1

I would take a look at the AxesGrid toolkit:

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:

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.

JoshAdel
  • 66,734
  • 27
  • 141
  • 140
0

you need subplot see this example:

http://matplotlib.sourceforge.net/examples/pylab_examples/subplot_toolbar.html

Andrea Zonca
  • 8,378
  • 9
  • 42
  • 70