matplotlib¶
Useful tkinter functions that use matplotlib
CustomToolbar
¶
Bases: NavigationToolbar2Tk
Customised version of matplotlib toolbar with added popout and copy functions
Source code in mmg_toolbox/tkguis/misc/matplotlib.py
copy_button()
¶
Copy figure to clipboard - doesn't currently work
Source code in mmg_toolbox/tkguis/misc/matplotlib.py
popout_figure()
¶
Create a new tk window and display figure
Source code in mmg_toolbox/tkguis/misc/matplotlib.py
add_rectangle(ax, left, bottom, width, height)
¶
Add rectangle to axes
Source code in mmg_toolbox/tkguis/misc/matplotlib.py
ini_image(frame, figure_size=None, figure_dpi=None)
¶
Create an empty image plot on a tk canvas with toolbar
fig, ax, plot_list, image, cbar, toolbar = ini_image(frame, figure_size, figure_dpi)
image.remove()
image = ax.pcolormesh(image_array, shading='auto')
colorbar.update_normal(image)
toolbar.update()
fig.canvas.draw()
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
frame
|
Misc
|
parent frame within which the figure will be placed. |
required |
figure_size
|
tuple[int, int] | None
|
size of the figure in inches [horiz, vert], passed to matplotlib.Figure() |
None
|
figure_dpi
|
int | None
|
figure DPI, passed to matplotlib.Figure() |
None
|
Returns:
| Type | Description |
|---|---|
tuple[Figure, Axes, list[Line2D], QuadMesh, Colorbar, CustomToolbar]
|
tuple[Figure, Axes, list[Line2D], Toolbar] |
Source code in mmg_toolbox/tkguis/misc/matplotlib.py
ini_plot(frame, figure_size=None, figure_dpi=None)
¶
Create a lineplot on a tk canvas with toolbar
fig, ax, line_list, toolbar = ini_plot(frame, figure_size, figure_dpi)
line_list.extend(ax.plot(x, y))
fig.canvas.draw()
toolbar.update()
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
frame
|
Misc
|
parent frame within which the figure will be placed. |
required |
figure_size
|
tuple[int, int] | None
|
size of the figure in inches [horiz, vert], passed to matplotlib.Figure() |
None
|
figure_dpi
|
int | None
|
figure DPI, passed to matplotlib.Figure() |
None
|
Returns:
| Type | Description |
|---|---|
tuple[Figure, Axes, list[Line2D], NavigationToolbar2Tk]
|
tuple[Figure, Axes, list[Line2D], Toolbar] |