Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Issue with ginput and adding points to an exisiting plot
#1
I am using ginput to plot additional points to an exisiting scatter plot, however when the new points are added the previously set x and y limits change. Attached is the code and visualizations to help explain the issue I am having.

#### CODE ####

import pandas as pd
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
import numpy as np

#### Read CSV File ####
mb = pd.read_csv('CuerpoGeologico.csv')
topo = pd.read_csv('Superficie.csv')


#### Create Subplots ####

fig = plt.figure()

ax1 = fig.add_subplot(211)
ax2 = fig.add_subplot(234)
ax3 = fig.add_subplot(235)
ax4 = fig.add_subplot(236)

#### PLot Data ####

ax1.scatter(mb.x, mb.y, c = 'blue', s=10)
ax2.scatter(mb.x, mb.z, c = 'magenta', s=1)
ax3.scatter(mb.y, mb.z, c = 'magenta', s=1)
ax4.scatter(mb.x, mb.y, c = 'magenta', s=1)

#### Set Grid #####
ax1.grid()

#### Set Axis Limits and Ticks ####
ax1.set_xticks(np.arange(3000, 9000, 1000))
ax1.set_yticks(np.arange(4000, 9000, 1000))

ax2.set_xlim([3000, 8000])
ax2.set_xticks([4000, 6000, 8000])
ax2.set_yticks(np.arange(0, 5000, 1000))

ax3.set_xticks([4000, 6000, 8000])
ax3.set_yticks(np.arange(0, 5000, 1000))

ax4.set_xlim([3000, 8000])
ax4.set_xticks([4000, 6000, 8000])
ax4.set_yticks(np.arange(4000, 9000, 1000))

#### Set Axis Labels ####
ax1.set_xlabel('East')
ax1.set_ylabel('North')

ax2.set_xlabel('East')
ax2.set_ylabel('Elevation')

ax3.set_xlabel('North')
ax3.set_ylabel('Elevation')

ax4.set_xlabel('East')
ax4.set_ylabel('North')

fig.tight_layout()

#### Select Drillhole Locations ####

collars = plt.ginput(2)

x = []
y = []

for i in collars:               #Create list of x and y coordinates of collars 
    x.append(i[0])
    y.append(i[1])
    
ax1.scatter(x, y, c='black', marker='x')        #Plot drillhole collars


İmage


İmage


As you can see after the points are placed in Figure_1b that the plot zooms in and the axis limits change. I would like for the figure to maintain the format of Figure_1a after placing the points with ginput.
buran wrote Oct-12-2019, 07:29 PM:
Please, use proper tags when post code, traceback, output, etc. This time I have added tags for you.
See BBcode help for more info.
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Adding markers to Folium map only adding last element. tantony 0 48 Oct-16-2019, 03:28 PM
Last Post: tantony
  How to plot vertically stacked plot with same x-axis and SriMekala 0 167 Jun-12-2019, 03:31 PM
Last Post: SriMekala
  plot points in loglog axes Tibas 0 643 Mar-06-2018, 06:56 PM
Last Post: Tibas

Forum Jump:


Users browsing this thread: 1 Guest(s)