Are there text / number input fields in matplotlib?

Are there text and / or numeric input fields for matplotlib ?

I saw the Slider widget, but it's something else. I want a simple number entry field.

+6
source share
2 answers

There are currently no widgets that could be used to enter numbers as text. If you had a small selection of discrete numbers, you could use RadioButton , or you could use a slider, as you said.

It would be best to create a complete graphical interface using Tkinter . This will allow you to add any GUI elements that you need. It is also possible to embed matplotlib graphics in Tkinter, as shown in the two examples here and.

+3
source

You are looking for an interactive TextBox widget that was added in 2.1:

 import numpy as np import matplotlib.pyplot as plt from matplotlib.widgets import TextBox fig, ax = plt.subplots() plt.subplots_adjust(bottom=0.2) t = np.arange(-2.0, 2.0, 0.001) ydata = t ** 2 initial_text = "t ** 2" l, = plt.plot(t, ydata, lw=2) def submit(text): ydata = eval(text) l.set_ydata(ydata) ax.set_ylim(np.min(ydata), np.max(ydata)) plt.draw() axbox = plt.axes([0.1, 0.05, 0.8, 0.075]) text_box = TextBox(axbox, 'Evaluate', initial=initial_text) text_box.on_submit(submit) plt.show() 
+5
source

Source: https://habr.com/ru/post/973613/


All Articles