Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 23276

How can I make it so y values do not cluster and the y values on y axis does not overlap?

$
0
0

2 issues, values in the y direction just cluster and not use the entire space of the subplot, no matter what, and then there is this black thing on y axis (sort of like y values but on top of one another), what is that? and how to fix these issues?

enter image description here

import tkinter as tkfrom tkinter import ttkimport matplotlib.pyplot as pltfrom matplotlib.backends.backend_tkagg import FigureCanvasTkAggimport threadingimport queueimport timefrom data import *import random# Function to continuously update the plotdef update_plot():    while True:        try:            # Get the latest point from the queue            point = point_queue.get_nowait()            index = point[1]            pairs = point[0].return_pairs()            color_ = [ 'FF5733', '8B0000', '00FF00', '006400', '6495ED', '00008B']            color_used = color_[index]            ax[0,0].plot(pairs[0][0], pairs[0][1],'o-', color_used)  # Assuming point is a tuple (x, y)            ax[1,0].plot(pairs[1][0], pairs[1][1], 'o-', color_used)  # Assuming point is a tuple (x, y)            ax[0,1].plot(pairs[2][0], pairs[2][1], 'o-', color_used)  # Assuming point is a tuple (x, y)            ax[1,1].plot(pairs[3][0], pairs[3][1], 'o-', color_used)  # Assuming point is a tuple (x, y)            # find mins            ax[0, 0].set_xlim(800, 2100)  # Start from 950, let matplotlib automatically adjust the upper limit            ax[1, 0].set_xlim(800, 2100)  # Start from 950, let matplotlib automatically adjust the upper limit            ax[0, 1].set_xlim(800, 2100)  # Start from 950, let matplotlib automatically adjust the upper limit            ax[1, 1].set_xlim(800, 2100)  # Start from 950, let matplotlib automatically adjust the upper limit            canvas.draw()        except queue.Empty:            pass        time.sleep(0.02)def add_point_to_queue(x, *args):    point_queue.put((x, *args))# Set up the Tkinter GUIroot = tk.Tk()root.title("Live Plot with Tkinter and Matplotlib")# Create a Matplotlib figure and embed it in the Tkinter windowfig, ax = plt.subplots(2, 2)ax[0, 0].set_xlabel('Frequency, Hz')ax[0, 0].set_ylabel('Gain, dB')ax[0, 0].set_title('Gain')ax[0, 1].set_ylabel('Detector')ax[0, 1].set_xlabel('Frequency, Hz')ax[0, 1].set_title('DetectorEn')ax[1, 0].set_ylabel('Detector')ax[1, 0].set_xlabel('Frequency, Hz')ax[1, 0].set_title('DetectorDis')ax[1, 1].set_ylabel('Temperature, C')ax[1, 1].set_xlabel('Frequency, Hz')ax[1, 1].set_title('Temperature')plt.tight_layout()canvas = FigureCanvasTkAgg(fig, master=root)canvas_widget = canvas.get_tk_widget()canvas_widget.pack(side=tk.TOP, fill=tk.BOTH, expand=True)point_queue = queue.Queue()update_thread = threading.Thread(target=update_plot)update_thread.daemon = Trueupdate_thread.start()def add_random_point():    for frequency in range(950, 1951, 100):        for i in range(6):            gain = random.randint(0, 100)            temperature = random.randint(79, 85)            input_power = random.randint(-10, -1)            meter_output = random.random()            pout_det = random.randint(2000, 2500)            pout_det_dis = random.randint(2100, 2600)            curr_point = Point(freq=frequency, gain=gain, Temperature=temperature, input_power=input_power, pout=meter_output, pout_det=pout_det, pout_det_dis=pout_det_dis)            add_point_to_queue(curr_point, i)add_random_point()root.mainloop()

I tried yslim and autoajusting


Viewing all articles
Browse latest Browse all 23276

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>