'Matplotlib Graph Only Has One y-axis Tick Mark? Plotting manually vs Tkinter Button
For some reason, my matplotlib isn't adding y-axis tick parts for the whole graph when calling my plotting function with a tkinter button. However, if I just call the plotting function manually, then the y-axis tick marks do show up. The data is being plotted correctly on both graphs. It's just one of them is missing most of the y-axis tick marks.
The graph when calling my plotting function with a tkinter button
The graph when calling my plotting function manually with a script
Note: The graphs may look like they're plotting two different things. They are the same, the scaling is just messed up for some reason.
This is the function my tkinter button calls. It's just setting some parameters and calling the graph function
def plotLightCurve():
myLCG.setCheckChoice(int(checkStarChoice.get()))
myLCG.setChoiceMag(check_star_mag_box.get())
myLCG.ConfigureFile()
myLCG.process_data()
myLCG.LCG_Plot()
This is the plot function itself
def LCG_Plot(self):
subplot = self.fig.add_subplot(111)
subplot.scatter(self.jd_list, self.c2_app_mag, label="c2 apparent mag.")
subplot.scatter(self.jd_list, self.c3_app_mag, label="c3 apparent mag.")
subplot.scatter(self.jd_list, self.c4_app_mag, label="c4 apparent mag.")
if self.source_c5_list[0] != 0:
subplot.scatter(self.jd_list, self.c5_app_mag, label="c5 apparent mag.")
if self.source_c6_list[0] != 0:
subplot.scatter(self.jd_list, self.c6_app_mag, label="c6 apparent mag.")
subplot.scatter(self.jd_list, self.t1_app_mag, label="t1 apparent mag.")
subplot.legend(title='Object Magnititudes', bbox_to_anchor=(1.05, 1.0), loc='upper left')
# subplot.tight_layout()
plt.scatter(self.jd_list, self.c2_app_mag, label="c2 apparent mag.")
plt.scatter(self.jd_list, self.c3_app_mag, label="c3 apparent mag.")
plt.scatter(self.jd_list, self.c4_app_mag, label="c4 apparent mag.")
plt.show()
Here is my script for manually plotting the graph. Note: The filepath, ChoiceMag, and CheckChoice are set elsewere in the tkinter version.
import LCGLib
myLCG = LCGLib.LCG()
myLCG.setFilePath('Measurements6.csv')
myLCG.setChoiceMag(8.91)
myLCG.setCheckChoice(1)
myLCG.ConfigureFile()
myLCG.process_data()
myLCG.LCG_Plot()
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|


