Skip to content

Commit c978c00

Browse files
committed
Added tikz logo generation
1 parent 73be38d commit c978c00

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

src/maxplotlib/logo/logo.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# import maxplotlib.canvas.canvas as canvas
2+
from maxplotlib.subfigure.tikz_figure import TikzFigure
3+
def tikz_logo():
4+
tikz = TikzFigure()
5+
6+
path_actions = ['draw', 'rounded corners', 'line width=3']
7+
8+
# M
9+
nodes = [[0,0],[0,3],[1,2],[2,3],[2,0]]
10+
for i, node_data in enumerate(nodes):
11+
tikz.add_node(node_data[0], node_data[1], f"M{i}", layer=0)
12+
tikz.add_path([f"M{i}" for i in range(len(nodes))], path_actions=path_actions, layer=1)
13+
14+
# P
15+
nodes = [[3,0],[3,3],[4,2.5],[4,1.5],[3,1]]
16+
for i, node_data in enumerate(nodes):
17+
tikz.add_node(node_data[0], node_data[1], f"P{i}", layer=0)
18+
tikz.add_path([f"P{i}" for i in range(len(nodes))], path_actions=path_actions, layer=1)
19+
20+
# L
21+
nodes = [[5,3],[5,0],[7,0]]
22+
for i, node_data in enumerate(nodes):
23+
tikz.add_node(node_data[0], node_data[1], f"L{i}", layer=0)
24+
tikz.add_path([f"L{i}" for i in range(len(nodes))], path_actions=path_actions, layer=1)
25+
26+
return tikz

src/maxplotlib/subfigure/tikz_figure.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,10 @@ def generate_tikz(self):
298298
tikz_script = figure_env
299299
tikz_script = self.add_tabs(tikz_script)
300300
return tikz_script
301-
301+
def savefig(self, filepath):
302+
tikz_code = self.generate_tikz()
303+
with open(filepath, 'w') as f:
304+
f.write(tikz_code)
302305
def generate_standalone(self):
303306
tikz_code = self.generate_tikz()
304307

0 commit comments

Comments
 (0)