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 ####

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
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


Possibly Related Threads…
Thread Author Replies Views Last Post
  creating two points (x,y) and adding them together.. azhag 2 7,341 Nov-20-2021, 07:22 AM
Last Post: ghoul
  Adding graph points and formating project_science 4 3,367 Jan-24-2021, 05:02 PM
Last Post: project_science
  How to plot intraday data of several days in one plot mistermister 3 3,974 Dec-15-2020, 07:43 PM
Last Post: deanhystad
  Adding markers to Folium map only adding last element. tantony 0 2,887 Oct-16-2019, 03:28 PM
Last Post: tantony
  How to plot vertically stacked plot with same x-axis and SriMekala 0 2,485 Jun-12-2019, 03:31 PM
Last Post: SriMekala
  plot points in loglog axes Tibas 0 2,729 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