Skip to content

Latest commit

 

History

History
119 lines (90 loc) · 4.86 KB

README.md

File metadata and controls

119 lines (90 loc) · 4.86 KB

maliang-mpl

https://xiaokang2022.github.io/maliang/

Extension package of maliang for matplotlib

Version Downloads Total Downloads Size
Watchers Forks Stars Issues Pull Requests Discussions

Insights

Star History Chart

📦 Installation

pip install maliang-mpl

👀 Preview

preview-1

import math

import matplotlib.figure
import numpy

import maliang
from maliang import mpl, theme

mpl.set_mpl_default_theme(theme.get_color_mode())

x = numpy.linspace(-math.tau, math.tau, 100)
y = numpy.sin(x)

figure = matplotlib.figure.Figure()
axes = figure.add_subplot()
axes.plot(x, y)

axes.set(xlabel='x', ylabel='y', title='Plotting based on the theme in tkt')
axes.legend(["$y=sin(x)$"])
axes.grid()

root = maliang.Tk((960, 720), title="maliang-mpl")
root.center()
canvas = maliang.Canvas(auto_zoom=True)
canvas.place(width=960, height=720)
figure_canvas = mpl.FigureCanvas(canvas, figure)
toolbar = mpl.FigureToolbar(canvas, figure_canvas)
figure_canvas.pack(side="top", fill="both", expand=True)

root.mainloop()

preview-2

import matplotlib.figure
import numpy

import maliang
from maliang import mpl, theme

mpl.set_mpl_default_theme(theme.get_color_mode())

figure = matplotlib.figure.Figure()
axes = figure.add_subplot(projection='3d')

colors = ['r', 'g', 'b', 'y']
yticks = [3, 2, 1, 0]

for c, k in zip(colors, yticks):
    xs = numpy.arange(20)
    ys = numpy.random.rand(20)
    cs = [c] * len(xs)
    cs[0] = 'c'
    axes.bar(xs, ys, zs=k, zdir='y', color=cs, alpha=0.7)

axes.set_xlabel('X')
axes.set_ylabel('Y')
axes.set_zlabel('Z')
axes.set_title("3D plotting with interoperability")

axes.set_yticks(yticks)

root = maliang.Tk((960, 720), title="maliang-mpl")
root.center()
canvas = maliang.Canvas(auto_update=True)
canvas.place(width=960, height=720)
figure_canvas = mpl.FigureCanvas(canvas, figure)
toolbar = mpl.FigureToolbar(canvas, figure_canvas)
figure_canvas.pack(side="top", fill="both", expand=True)

root.mainloop()