0

I have a pandas dataframe, which I amusing to plot several variables against one another. A snippet is:

infile = 'Extent_Processed.csv'

columns = ['COUNTRY','CIFOR_Area','GMW_Area','Giri_Area','Hamilton_Area','SpaldingHa']

csv = pd.read_csv(infile,usecols=columns)

figure, axes = plt.subplots(nrows=5, ncols=5)

#CIFOR
axes[0,0].scatter(csv.CIFOR_Area, csv.CIFOR_Area, label='CIFOR', c='gray', s=1)
axes[0,0].set_ylabel('CIFOR Area (ha)')
axes[0,0].set_xlim(0, 1500000)
axes[0,0].set_ylim(0, 1500000)
axes[0,0].set_xticks([0,500000,1000000,1500000])
axes[0,0].set_yticks([0,500000,1000000,1500000])

this gets me the 20 plots I would like but I would like to add a 1:1 line onto each of the plots. I have tried something simple like:

axes[0,0].plot(np.array([0,0]), np.array([1500000,1500000]), linewidth=0.1, c='black', linestyle='--')

but this does not show up in the plot. Is there a way to create a 1:1 line based on the xlim and slim extents?

GeoMonkey
  • 1,615
  • 7
  • 28
  • 56
  • Could you add some example of your data and also a draft of your desired graph? – Daniel Lima Mar 19 '21 at 19:20
  • The line`y=x` (slope 1, no intercept) or a diagonal line from the bottom left to the top right? – ALollz Mar 19 '21 at 19:22
  • Diagonal line from bottom left to top right. So from coords (0,0) to (1500000, 1500000). Each of the 20 plots will be set by these x and y limits – GeoMonkey Mar 19 '21 at 19:25
  • Well sine that's the line y=x then you can use https://stackoverflow.com/questions/25497402/adding-y-x-to-a-matplotlib-scatter-plot-if-i-havent-kept-track-of-all-the-data, the line is plotted in "here's the good part" – ALollz Mar 19 '21 at 19:28
  • bingo! As its repetition of an existing answer, should I delete this? Otherwise, happy to accept if you put as answer. – GeoMonkey Mar 19 '21 at 19:33

0 Answers0