Python Forum
Issue with ginput and adding points to an exisiting plot
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


[Image: view?usp=sharing]

[Image: view?usp=sharing]

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.
Reply


Messages In This Thread
Issue with ginput and adding points to an exisiting plot - by gaminer - Oct-12-2019, 07:08 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  creating two points (x,y) and adding them together.. azhag 2 2,992 Nov-20-2021, 07:22 AM
Last Post: ghoul
  Adding graph points and formating project_science 4 2,345 Jan-24-2021, 05:02 PM
Last Post: project_science
  How to plot intraday data of several days in one plot mistermister 3 2,854 Dec-15-2020, 07:43 PM
Last Post: deanhystad
  Adding markers to Folium map only adding last element. tantony 0 2,094 Oct-16-2019, 03:28 PM
Last Post: tantony
  How to plot vertically stacked plot with same x-axis and SriMekala 0 1,884 Jun-12-2019, 03:31 PM
Last Post: SriMekala
  plot points in loglog axes Tibas 0 2,201 Mar-06-2018, 06:56 PM
Last Post: Tibas

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020