tikzplotly 0.1.7__tar.gz → 0.2.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. {tikzplotly-0.1.7 → tikzplotly-0.2.1}/PKG-INFO +24 -14
  2. {tikzplotly-0.1.7 → tikzplotly-0.2.1}/README.md +18 -11
  3. {tikzplotly-0.1.7 → tikzplotly-0.2.1}/pyproject.toml +5 -3
  4. tikzplotly-0.2.1/src/tests/test_bars.py +310 -0
  5. {tikzplotly-0.1.7 → tikzplotly-0.2.1}/src/tests/test_heatmaps.py +9 -9
  6. tikzplotly-0.2.1/src/tests/test_histograms.py +284 -0
  7. {tikzplotly-0.1.7 → tikzplotly-0.2.1}/src/tests/test_line_charts.py +53 -2
  8. {tikzplotly-0.1.7 → tikzplotly-0.2.1}/src/tests/test_markers.py +3 -2
  9. tikzplotly-0.2.1/src/tests/test_polar.py +656 -0
  10. tikzplotly-0.2.1/src/tests/test_scatter3d.py +138 -0
  11. tikzplotly-0.2.1/src/tikzplotly/__about__.py +7 -0
  12. tikzplotly-0.2.1/src/tikzplotly/__init__.py +14 -0
  13. {tikzplotly-0.1.7 → tikzplotly-0.2.1}/src/tikzplotly/_annotations.py +18 -7
  14. tikzplotly-0.2.1/src/tikzplotly/_axis.py +204 -0
  15. tikzplotly-0.2.1/src/tikzplotly/_bar.py +94 -0
  16. {tikzplotly-0.1.7 → tikzplotly-0.2.1}/src/tikzplotly/_color.py +88 -24
  17. {tikzplotly-0.1.7 → tikzplotly-0.2.1}/src/tikzplotly/_dash.py +4 -1
  18. tikzplotly-0.2.1/src/tikzplotly/_data.py +63 -0
  19. tikzplotly-0.2.1/src/tikzplotly/_dataContainer.py +226 -0
  20. {tikzplotly-0.1.7 → tikzplotly-0.2.1}/src/tikzplotly/_heatmap.py +12 -6
  21. tikzplotly-0.2.1/src/tikzplotly/_histogram.py +156 -0
  22. {tikzplotly-0.1.7 → tikzplotly-0.2.1}/src/tikzplotly/_marker.py +20 -0
  23. tikzplotly-0.2.1/src/tikzplotly/_polar.py +216 -0
  24. tikzplotly-0.2.1/src/tikzplotly/_save.py +246 -0
  25. {tikzplotly-0.1.7 → tikzplotly-0.2.1}/src/tikzplotly/_scatter.py +24 -19
  26. tikzplotly-0.2.1/src/tikzplotly/_scatter3d.py +104 -0
  27. {tikzplotly-0.1.7 → tikzplotly-0.2.1}/src/tikzplotly/_tex.py +59 -14
  28. tikzplotly-0.2.1/src/tikzplotly/_utils.py +229 -0
  29. {tikzplotly-0.1.7 → tikzplotly-0.2.1}/src/tikzplotly.egg-info/PKG-INFO +24 -14
  30. {tikzplotly-0.1.7 → tikzplotly-0.2.1}/src/tikzplotly.egg-info/SOURCES.txt +13 -0
  31. tikzplotly-0.2.1/tests/test_bars.py +57 -0
  32. tikzplotly-0.2.1/tests/test_histograms.py +95 -0
  33. {tikzplotly-0.1.7 → tikzplotly-0.2.1}/tests/test_markers.py +18 -2
  34. tikzplotly-0.2.1/tests/test_polar.py +278 -0
  35. {tikzplotly-0.1.7 → tikzplotly-0.2.1}/tests/test_scatter.py +88 -2
  36. tikzplotly-0.2.1/tests/test_scatter3d.py +100 -0
  37. tikzplotly-0.2.1/tests/test_specific.py +52 -0
  38. tikzplotly-0.2.1/tests/test_tikzplotly.py +40 -0
  39. tikzplotly-0.1.7/src/tikzplotly/__about__.py +0 -1
  40. tikzplotly-0.1.7/src/tikzplotly/__init__.py +0 -4
  41. tikzplotly-0.1.7/src/tikzplotly/_axis.py +0 -127
  42. tikzplotly-0.1.7/src/tikzplotly/_data.py +0 -35
  43. tikzplotly-0.1.7/src/tikzplotly/_dataContainer.py +0 -91
  44. tikzplotly-0.1.7/src/tikzplotly/_save.py +0 -145
  45. tikzplotly-0.1.7/src/tikzplotly/_utils.py +0 -132
  46. tikzplotly-0.1.7/tests/test_tikzplotly.py +0 -6
  47. {tikzplotly-0.1.7 → tikzplotly-0.2.1}/LICENSE +0 -0
  48. {tikzplotly-0.1.7 → tikzplotly-0.2.1}/setup.cfg +0 -0
  49. {tikzplotly-0.1.7 → tikzplotly-0.2.1}/src/tikzplotly.egg-info/dependency_links.txt +0 -0
  50. {tikzplotly-0.1.7 → tikzplotly-0.2.1}/src/tikzplotly.egg-info/requires.txt +0 -0
  51. {tikzplotly-0.1.7 → tikzplotly-0.2.1}/src/tikzplotly.egg-info/top_level.txt +0 -0
  52. {tikzplotly-0.1.7 → tikzplotly-0.2.1}/tests/test_heatmap.py +0 -0
@@ -1,7 +1,7 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: tikzplotly
3
- Version: 0.1.7
4
- Summary: Convert plotly figures to LaTeX / tikz figures
3
+ Version: 0.2.1
4
+ Summary: Convert plotly figures to LaTeX / TikZ figures
5
5
  Author-email: Thomas Saigre <tikzplotly@outlook.fr>
6
6
  License: The MIT License (MIT)
7
7
 
@@ -30,9 +30,11 @@ Keywords: plotly,latex,tikz,figure,conversion,graphics
30
30
  Classifier: Development Status :: 5 - Production/Stable
31
31
  Classifier: Programming Language :: Python
32
32
  Classifier: Programming Language :: Python :: 3
33
- Classifier: Programming Language :: Python :: 3.8
34
33
  Classifier: Programming Language :: Python :: 3.9
35
34
  Classifier: Programming Language :: Python :: 3.10
35
+ Classifier: Programming Language :: Python :: 3.11
36
+ Classifier: Programming Language :: Python :: 3.12
37
+ Classifier: Programming Language :: Python :: 3.13
36
38
  Classifier: License :: OSI Approved :: MIT License
37
39
  Classifier: Operating System :: OS Independent
38
40
  Classifier: Topic :: Multimedia :: Graphics :: Graphics Conversion
@@ -44,24 +46,32 @@ Requires-Dist: plotly
44
46
  Requires-Dist: pillow
45
47
  Provides-Extra: dev
46
48
  Requires-Dist: pandas; extra == "dev"
49
+ Dynamic: license-file
50
+
51
+ ![logo-tikzplotly](https://raw.githubusercontent.com/thomas-saigre/tikzplotly/main/docs/assets/logo.svg "Tikzplotly")
47
52
 
48
- ![logo-tikzplotly](https://raw.githubusercontent.com/thomas-saigre/tikzplotly/main/doc/img/logo.svg "Tikzplotly")
49
53
 
50
54
  [![PyPi Version](https://img.shields.io/pypi/v/tikzplotly.svg?style=flat-square)](https://pypi.org/project/tikzplotly)
55
+ [![PyPi Downloads](https://img.shields.io/pypi/dm/tikzplotly.svg?style=flat-square)](https://pypi.org/project/tikzplotly)
56
+ [![PyPi License](https://img.shields.io/pypi/l/tikzplotly.svg?style=flat-square)](https://pypi.org/project/tikzplotly)
51
57
  [![PyPI pyversions](https://img.shields.io/pypi/pyversions/tikzplotly.svg?style=flat-square)](https://pypi.org/pypi/tikzplotly/)
52
58
 
59
+ [![GitHub release](https://img.shields.io/github/release/thomas-saigre/tikzplotly.svg?style=flat-square)](https://github.com/thomas-saigre/tikzplotly/releases)
53
60
  [![Issue](https://img.shields.io/github/issues-raw/thomas-saigre/tikzplotly?style=flat-square)](https://github.com/thomas-saigre/tikzplotly/issues)
54
- [![codecov](https://img.shields.io/codecov/c/github/thomas-saigre/tikzplotly.svg?style=flat-square)](https://codecov.io/gh/thomas-saigre/tikzplotly)
61
+ [![codecov](https://img.shields.io/codecov/c/github/thomas-saigre/tikzplotly?token=NH7GAHLBLE&style=flat-square&logo=codecov
62
+ )](https://codecov.io/gh/thomas-saigre/tikzplotly)
55
63
  ![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/thomas-saigre/tikzplotly/ci.yml?style=flat-square)
56
64
 
57
65
 
58
66
  # Tikzplotly
59
67
 
60
- Convert [plotly](https://plotly.com/python/) figures to tikz code for inclusion into [PGFPlots](https://www.ctan.org/pkg/pgfplots) ([PGF/TikZ](https://www.ctan.org/pkg/pgf)) figures.
68
+ Convert [plotly](https://plotly.com/python/) figures to TikZ code for inclusion into [PGFPlots](https://www.ctan.org/pkg/pgfplots) ([PGF/TikZ](https://www.ctan.org/pkg/pgf)) figures.
61
69
 
62
70
  This results in a ti*k*z code, that can be easily included into your LaTeX document.
63
71
  This also allows to easily edit the content of the figure.
64
72
 
73
+ More details can be found in [the documentation](https://thomas-saigre.github.io/tikzplotly/).
74
+
65
75
  ## Example
66
76
 
67
77
  The following Python code
@@ -78,7 +88,8 @@ tikzplotly.save("example.tex", fig)
78
88
  will result in the following ti*k*z code
79
89
 
80
90
  ```latex
81
- \pgfplotstableread{data0 Australia New_Zealand
91
+ \pgfplotstableread{
92
+ x Australia NewZealand
82
93
  1952 69.12 69.39
83
94
  1957 70.33 70.26
84
95
  1962 70.93 71.24
@@ -91,7 +102,7 @@ will result in the following ti*k*z code
91
102
  1997 78.83 77.55
92
103
  2002 80.37 79.11
93
104
  2007 81.235 80.204
94
- }\dataZ
105
+ }\dataA
95
106
 
96
107
  \begin{tikzpicture}
97
108
 
@@ -100,11 +111,11 @@ will result in the following ti*k*z code
100
111
 
101
112
  \begin{axis}[
102
113
  xlabel=year,
103
- ylabel=lifeExp,
114
+ ylabel=lifeExp
104
115
  ]
105
- \addplot+ [mark=*, solid, color=636efa, mark options={solid, draw=636efa}] table[y=Australia] {\dataZ};
116
+ \addplot+ [mark=*, solid, color=636efa] table[y=Australia] {\dataA};
106
117
  \addlegendentry{Australia}
107
- \addplot+ [mark=*, solid, color=EF553B, mark options={solid, draw=EF553B}] table[y=New_Zealand] {\dataZ};
118
+ \addplot+ [mark=*, solid, color=EF553B] table[y=NewZealand] {\dataA};
108
119
  \addlegendentry{New Zealand}
109
120
  \end{axis}
110
121
  \end{tikzpicture}
@@ -142,8 +153,7 @@ To correctly compile the document, you will need to add the following packages t
142
153
 
143
154
  * This module is in development and new features are added bit by bit, when needed. If you have a feature request, please open an issue with the plotly figure you want to convert and the desired output.
144
155
  You can also submit a pull request with the desired feature !
145
- * Some feature can result in different output between the plotly figure and the tikz figure, for instance the size of markers.
146
- * More details in [doc/NB.md](doc/NB.md).
156
+ * Some feature can result in different output between the plotly figure and the TikZ figure, for instance the size of markers, more details can be found in [the documentation](https://thomas-saigre.github.io/tikzplotly/).
147
157
 
148
158
 
149
159
  ## References
@@ -1,20 +1,27 @@
1
- ![logo-tikzplotly](https://raw.githubusercontent.com/thomas-saigre/tikzplotly/main/doc/img/logo.svg "Tikzplotly")
1
+ ![logo-tikzplotly](https://raw.githubusercontent.com/thomas-saigre/tikzplotly/main/docs/assets/logo.svg "Tikzplotly")
2
+
2
3
 
3
4
  [![PyPi Version](https://img.shields.io/pypi/v/tikzplotly.svg?style=flat-square)](https://pypi.org/project/tikzplotly)
5
+ [![PyPi Downloads](https://img.shields.io/pypi/dm/tikzplotly.svg?style=flat-square)](https://pypi.org/project/tikzplotly)
6
+ [![PyPi License](https://img.shields.io/pypi/l/tikzplotly.svg?style=flat-square)](https://pypi.org/project/tikzplotly)
4
7
  [![PyPI pyversions](https://img.shields.io/pypi/pyversions/tikzplotly.svg?style=flat-square)](https://pypi.org/pypi/tikzplotly/)
5
8
 
9
+ [![GitHub release](https://img.shields.io/github/release/thomas-saigre/tikzplotly.svg?style=flat-square)](https://github.com/thomas-saigre/tikzplotly/releases)
6
10
  [![Issue](https://img.shields.io/github/issues-raw/thomas-saigre/tikzplotly?style=flat-square)](https://github.com/thomas-saigre/tikzplotly/issues)
7
- [![codecov](https://img.shields.io/codecov/c/github/thomas-saigre/tikzplotly.svg?style=flat-square)](https://codecov.io/gh/thomas-saigre/tikzplotly)
11
+ [![codecov](https://img.shields.io/codecov/c/github/thomas-saigre/tikzplotly?token=NH7GAHLBLE&style=flat-square&logo=codecov
12
+ )](https://codecov.io/gh/thomas-saigre/tikzplotly)
8
13
  ![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/thomas-saigre/tikzplotly/ci.yml?style=flat-square)
9
14
 
10
15
 
11
16
  # Tikzplotly
12
17
 
13
- Convert [plotly](https://plotly.com/python/) figures to tikz code for inclusion into [PGFPlots](https://www.ctan.org/pkg/pgfplots) ([PGF/TikZ](https://www.ctan.org/pkg/pgf)) figures.
18
+ Convert [plotly](https://plotly.com/python/) figures to TikZ code for inclusion into [PGFPlots](https://www.ctan.org/pkg/pgfplots) ([PGF/TikZ](https://www.ctan.org/pkg/pgf)) figures.
14
19
 
15
20
  This results in a ti*k*z code, that can be easily included into your LaTeX document.
16
21
  This also allows to easily edit the content of the figure.
17
22
 
23
+ More details can be found in [the documentation](https://thomas-saigre.github.io/tikzplotly/).
24
+
18
25
  ## Example
19
26
 
20
27
  The following Python code
@@ -31,7 +38,8 @@ tikzplotly.save("example.tex", fig)
31
38
  will result in the following ti*k*z code
32
39
 
33
40
  ```latex
34
- \pgfplotstableread{data0 Australia New_Zealand
41
+ \pgfplotstableread{
42
+ x Australia NewZealand
35
43
  1952 69.12 69.39
36
44
  1957 70.33 70.26
37
45
  1962 70.93 71.24
@@ -44,7 +52,7 @@ will result in the following ti*k*z code
44
52
  1997 78.83 77.55
45
53
  2002 80.37 79.11
46
54
  2007 81.235 80.204
47
- }\dataZ
55
+ }\dataA
48
56
 
49
57
  \begin{tikzpicture}
50
58
 
@@ -53,11 +61,11 @@ will result in the following ti*k*z code
53
61
 
54
62
  \begin{axis}[
55
63
  xlabel=year,
56
- ylabel=lifeExp,
64
+ ylabel=lifeExp
57
65
  ]
58
- \addplot+ [mark=*, solid, color=636efa, mark options={solid, draw=636efa}] table[y=Australia] {\dataZ};
66
+ \addplot+ [mark=*, solid, color=636efa] table[y=Australia] {\dataA};
59
67
  \addlegendentry{Australia}
60
- \addplot+ [mark=*, solid, color=EF553B, mark options={solid, draw=EF553B}] table[y=New_Zealand] {\dataZ};
68
+ \addplot+ [mark=*, solid, color=EF553B] table[y=NewZealand] {\dataA};
61
69
  \addlegendentry{New Zealand}
62
70
  \end{axis}
63
71
  \end{tikzpicture}
@@ -95,8 +103,7 @@ To correctly compile the document, you will need to add the following packages t
95
103
 
96
104
  * This module is in development and new features are added bit by bit, when needed. If you have a feature request, please open an issue with the plotly figure you want to convert and the desired output.
97
105
  You can also submit a pull request with the desired feature !
98
- * Some feature can result in different output between the plotly figure and the tikz figure, for instance the size of markers.
99
- * More details in [doc/NB.md](doc/NB.md).
106
+ * Some feature can result in different output between the plotly figure and the TikZ figure, for instance the size of markers, more details can be found in [the documentation](https://thomas-saigre.github.io/tikzplotly/).
100
107
 
101
108
 
102
109
  ## References
@@ -109,4 +116,4 @@ You can also submit a pull request with the desired feature !
109
116
 
110
117
  ## License
111
118
 
112
- This project is licensed under the MIT [License](LICENSE).
119
+ This project is licensed under the MIT [License](LICENSE).
@@ -4,8 +4,8 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "tikzplotly"
7
- version = "0.1.7"
8
- description = "Convert plotly figures to LaTeX / tikz figures"
7
+ version = "0.2.1"
8
+ description = "Convert plotly figures to LaTeX / TikZ figures"
9
9
  readme = "README.md"
10
10
  authors = [{name = "Thomas Saigre", email = "tikzplotly@outlook.fr"}]
11
11
  license = { file = "LICENSE" }
@@ -13,9 +13,11 @@ classifiers = [
13
13
  "Development Status :: 5 - Production/Stable",
14
14
  "Programming Language :: Python",
15
15
  "Programming Language :: Python :: 3",
16
- "Programming Language :: Python :: 3.8",
17
16
  "Programming Language :: Python :: 3.9",
18
17
  "Programming Language :: Python :: 3.10",
18
+ "Programming Language :: Python :: 3.11",
19
+ "Programming Language :: Python :: 3.12",
20
+ "Programming Language :: Python :: 3.13",
19
21
  "License :: OSI Approved :: MIT License",
20
22
  "Operating System :: OS Independent",
21
23
  "Topic :: Multimedia :: Graphics :: Graphics Conversion",
@@ -0,0 +1,310 @@
1
+ # From https://plotly.com/python/bar-charts/ and https://plotly.com/python/horizontal-bar-charts/
2
+ import plotly
3
+ import plotly.express as px
4
+ import pandas as pd
5
+ import plotly.graph_objects as go
6
+ from plotly.subplots import make_subplots
7
+
8
+ import numpy as np
9
+ import tikzplotly
10
+ import os
11
+ from warnings import warn
12
+ from tikzplotly._tex import tex_create_document, tex_begin_environment, tex_end_environment, tex_end_all_environment
13
+
14
+ def fig_vertical1():
15
+
16
+ data_canada = px.data.gapminder().query("country == 'Canada'")
17
+ fig = px.bar(data_canada, x='year', y='pop')
18
+
19
+ # fig.show()
20
+ # fig.write_image(os.path.join(file_directory, "outputs", "test_bars", "fig1.png"))
21
+
22
+ return fig, "Bar chart with Plotly Express"
23
+
24
+ def fig_vertical2():
25
+
26
+ long_df = px.data.medals_long()
27
+
28
+ fig = px.bar(long_df, x="nation", y="count", color="medal", title="Long-Form Input")
29
+
30
+ # fig.show()
31
+ # fig.write_image(os.path.join(file_directory, "outputs", "test_bars", "fig2.png"))
32
+
33
+ return fig, "Bar charts with Long Format Data"
34
+
35
+ def fig_vertical3():
36
+
37
+ wide_df = px.data.medals_wide()
38
+ fig = px.bar(
39
+ wide_df,
40
+ x="nation",
41
+ y=["gold", "silver", "bronze"],
42
+ title="Wide-Form Input",
43
+ color_discrete_map={
44
+ "gold": "gold",
45
+ "silver": "silver",
46
+ "bronze": "#cd7f32"
47
+ }
48
+ )
49
+ fig.update_traces(marker_line_width=2, marker_line_color="black")
50
+ # fig.show()
51
+ # fig.write_image(os.path.join(file_directory, "outputs", "test_bars", "fig3.png"))
52
+
53
+ return fig, "Bar charts with Wide Format Data"
54
+
55
+ def fig_vertical5():
56
+
57
+ df = px.data.gapminder().query("country == 'Canada'")
58
+ fig = px.bar(df, x='year', y='pop',
59
+ hover_data=['lifeExp', 'gdpPercap'], color='lifeExp',
60
+ labels={'pop':'population of Canada'}, height=400)
61
+
62
+ # fig.show()
63
+ # fig.write_image(os.path.join(file_directory, "outputs", "test_bars", "fig5.png"))
64
+
65
+ return fig, "Colored Bars"
66
+
67
+ def fig_vertical6():
68
+
69
+ df = px.data.gapminder().query("continent == 'Oceania'")
70
+ fig = px.bar(df, x='year', y='pop',
71
+ hover_data=['lifeExp', 'gdpPercap'], color='country',
72
+ labels={'pop':'population of Canada'}, height=400)
73
+
74
+ # fig.show()
75
+ # fig.write_image(os.path.join(file_directory, "outputs", "test_bars", "fig5bis.png"))
76
+
77
+ return fig, "Colored Bars"
78
+
79
+ def fig_vertical7():
80
+
81
+ df = px.data.tips()
82
+ fig = px.bar(df, x="sex", y="total_bill", color='time')
83
+
84
+ # fig.show()
85
+ # fig.write_image(os.path.join(file_directory, "outputs", "test_bars", "fig6.png"))
86
+
87
+ return fig, "Stacked vs Grouped Bars"
88
+
89
+ def fig_vertical8():
90
+
91
+ df = px.data.tips()
92
+ fig = px.bar(df, x="sex", y="total_bill",
93
+ color='smoker', barmode='group',
94
+ height=400)
95
+
96
+ # fig.show()
97
+ # fig.write_image(os.path.join(file_directory, "outputs", "test_bars", "fig6bis.png"))
98
+
99
+ return fig, "Stacked vs Grouped Bars"
100
+
101
+ def fig_vertical9():
102
+
103
+ df = px.data.tips()
104
+ fig = px.histogram(df, x="sex", y="total_bill",
105
+ color='smoker', barmode='group',
106
+ height=400)
107
+
108
+ # fig.show()
109
+ # fig.write_image(os.path.join(file_directory, "outputs", "test_bars", "fig7.png"))
110
+
111
+ return fig, "Aggregating into Single Colored Bars"
112
+
113
+ def fig_vertical10():
114
+
115
+ df = px.data.tips()
116
+ fig = px.histogram(df, x="sex", y="total_bill",
117
+ color='smoker', barmode='group',
118
+ histfunc='avg',
119
+ height=400)
120
+
121
+ # fig.show()
122
+ # fig.write_image(os.path.join(file_directory, "outputs", "test_bars", "fig7bis.png"))
123
+
124
+ return fig, "Aggregating into Single Colored Bars"
125
+
126
+ def fig_vertical11():
127
+
128
+ df = px.data.medals_long()
129
+
130
+ fig = px.bar(df, x="medal", y="count", color="nation", text_auto=True)
131
+
132
+ # fig.show()
133
+ # fig.write_image(os.path.join(file_directory, "outputs", "test_bars", "fig8.png"))
134
+
135
+ return fig, "Bar Charts with Text"
136
+
137
+ def fig_vertical12():
138
+
139
+ df = px.data.medals_long()
140
+
141
+ fig = px.bar(df, x="medal", y="count", color="nation", text="nation")
142
+
143
+ # fig.show()
144
+ # fig.write_image(os.path.join(file_directory, "outputs", "test_bars", "fig8bis.png"))
145
+
146
+ return fig, "Bar Charts with Text"
147
+
148
+ def fig_vertical13():
149
+
150
+ df = px.data.gapminder().query("continent == 'Europe' and year == 2007 and pop > 2.e6")
151
+ fig = px.bar(df, y='pop', x='country', text_auto='.2s',
152
+ title="Default: various text sizes, positions and angles")
153
+
154
+ # fig.show()
155
+ # fig.write_image(os.path.join(file_directory, "outputs", "test_bars", "fig8ter.png"))
156
+
157
+ return fig, "Bar Charts with Text"
158
+
159
+ def fig_vertical14():
160
+
161
+ df = px.data.gapminder().query("continent == 'Europe' and year == 2007 and pop > 2.e6")
162
+ fig = px.bar(df, y='pop', x='country', text_auto='.2s',
163
+ title="Controlled text sizes, positions and angles")
164
+ fig.update_traces(textfont_size=12, textangle=0, textposition="outside", cliponaxis=False)
165
+
166
+ # fig.show()
167
+ # fig.write_image(os.path.join(file_directory, "outputs", "test_bars", "fig8quater.png"))
168
+
169
+ return fig, "Bar Charts with Text"
170
+
171
+ def fig_vertical15():
172
+
173
+ df = px.data.medals_long()
174
+
175
+ fig = px.bar(df, x="medal", y="count", color="nation",
176
+ pattern_shape="nation", pattern_shape_sequence=[".", "x", "+"])
177
+
178
+ # fig.show()
179
+ # fig.write_image(os.path.join(file_directory, "outputs", "test_bars", "fig9.png"))
180
+
181
+ return fig, "Pattern fills"
182
+
183
+ def fig_vertical16():
184
+ animals=['giraffes', 'orangutans', 'monkeys']
185
+
186
+ fig = go.Figure([go.Bar(x=animals, y=[20, 14, 23])])
187
+
188
+ # fig.show()
189
+ # fig.write_image(os.path.join(file_directory, "outputs", "test_bars", "fig10.png"))
190
+
191
+ return fig, "Basic Bar Charts with plotly graph objects"
192
+
193
+ def fig_vertical17():
194
+ animals=['giraffes', 'orangutans', 'monkeys']
195
+
196
+ fig = go.Figure(data=[
197
+ go.Bar(name='SF Zoo', x=animals, y=[20, 14, 23]),
198
+ go.Bar(name='LA Zoo', x=animals, y=[12, 18, 29])
199
+ ])
200
+ # Change the bar mode
201
+ fig.update_layout(barmode='group')
202
+
203
+ # fig.show()
204
+ # fig.write_image(os.path.join(file_directory, "outputs", "test_bars", "fig11.png"))
205
+
206
+ return fig, "Grouped Bar Chart"
207
+
208
+ def fig_vertical18():
209
+ animals=['giraffes', 'orangutans', 'monkeys']
210
+
211
+ fig = go.Figure(data=[
212
+ go.Bar(name='SF Zoo', x=animals, y=[20, 14, 23]),
213
+ go.Bar(name='LA Zoo', x=animals, y=[12, 18, 29])
214
+ ])
215
+ # Change the bar mode
216
+ fig.update_layout(barmode='stack')
217
+
218
+ # fig.show()
219
+ # fig.write_image(os.path.join(file_directory, "outputs", "test_bars", "fig12.png"))
220
+
221
+ return fig, "Stacked Bar Chart"
222
+
223
+ def fig_vertical19():
224
+ x = [1, 2, 3, 4]
225
+
226
+ fig = go.Figure()
227
+ fig.add_trace(go.Bar(x=x, y=[1, 4, 9, 16]))
228
+ fig.add_trace(go.Bar(x=x, y=[6, -8, -4.5, 8]))
229
+ fig.add_trace(go.Bar(x=x, y=[-15, -3, 4.5, -8]))
230
+ fig.add_trace(go.Bar(x=x, y=[-1, 3, -3, -4]))
231
+
232
+ fig.update_layout(barmode='relative', title_text='Relative Barmode')
233
+
234
+ # fig.show()
235
+ # fig.write_image(os.path.join(file_directory, "outputs", "test_bars", "fig13.png"))
236
+
237
+ return fig, "Bar Chart with Relative Barmode"
238
+
239
+ def fig_horizontal1():
240
+ df = px.data.tips()
241
+ fig = px.bar(df, x="total_bill", y="day", orientation='h')
242
+ return fig, "Horizontal figure"
243
+
244
+ def fig_horizontal2():
245
+ fig = go.Figure(go.Bar(
246
+ x=[20, 14, 23],
247
+ y=['giraffes', 'orangutans', 'monkeys'],
248
+ orientation='h'))
249
+ return fig, "Basic Horizontal Bar Chart"
250
+
251
+
252
+ if __name__ == "__main__":
253
+
254
+ print("Tikzploty : ", tikzplotly.__version__)
255
+ print("Plotly : ", plotly.__version__)
256
+ print("Test histograms")
257
+
258
+
259
+ file_directory = os.path.dirname(os.path.abspath(__file__))
260
+
261
+ functions = [
262
+ ("vertical1", fig_vertical1),
263
+ ("vertical2", fig_vertical2),
264
+ ("vertical3", fig_vertical3),
265
+ ("vertical5", fig_vertical5),
266
+ ("vertical6", fig_vertical6),
267
+ ("vertical7", fig_vertical7), # Stacked bars are not supported yet.
268
+ ("vertical8", fig_vertical8), # Stacked bars are not supported yet.
269
+ ("vertical9", fig_vertical9), # Aggregated bars are not supported yet.
270
+ ("vertical10", fig_vertical10), # Aggregated bars are not supported yet.
271
+ ("vertical11", fig_vertical11), # Text template is not supported yet.
272
+ ("vertical12", fig_vertical12), # Text template is not supported yet.
273
+ ("vertical13", fig_vertical13), # Text template is not supported yet.
274
+ ("vertical14", fig_vertical14), # Text template is not supported yet.
275
+ ("vertical15", fig_vertical15), # Pattern fills are not supported yet.
276
+ ("vertical16", fig_vertical16),
277
+ ("vertical17", fig_vertical17),
278
+ ("vertical18", fig_vertical18),
279
+ ("vertical19", fig_vertical19),
280
+ ("horizontal1", fig_horizontal1),
281
+ ("horizontal2", fig_horizontal2),
282
+ ]
283
+
284
+ main_tex_content = tex_create_document(options="twocolumn", compatibility="newest")
285
+ main_tex_content += "\\usepackage[left=1cm, right=1cm, top=1cm, bottom=1cm]{geometry}\n"
286
+ main_tex_content += "\n"
287
+ stack_env = []
288
+ main_tex_content += tex_begin_environment("document", stack_env) + '\n'
289
+
290
+ output_path = os.path.join(file_directory, "outputs", "test_bars")
291
+ if not os.path.exists(output_path):
292
+ os.makedirs(output_path)
293
+
294
+ for i, f in functions:
295
+ print(f"Figure {i}")
296
+ fig, title = f()
297
+ data = fig.data
298
+ save_path = os.path.join(file_directory, "outputs", "test_bars", "fig{}.tex".format(i))
299
+ tikzplotly.save(save_path, fig)
300
+ main_tex_content += tex_begin_environment("figure", stack_env)
301
+ main_tex_content += " \\input{fig" + str(i) + ".tex}\n"
302
+ main_tex_content += " \\caption{" + title + "}\n"
303
+ main_tex_content += tex_end_environment(stack_env) + '\n'
304
+
305
+ main_tex_content += "\n" + tex_end_all_environment(stack_env)
306
+
307
+ main_tex_path = os.path.join(file_directory, "outputs", "test_bars", "main.tex")
308
+ print("Save main tex file : ", main_tex_path)
309
+ with open(main_tex_path, "w") as f:
310
+ f.write(main_tex_content)
@@ -166,16 +166,16 @@ if __name__ == "__main__":
166
166
  file_directory = os.path.dirname(os.path.abspath(__file__))
167
167
 
168
168
  functions = [
169
- # ("1", fig1),
170
- # ("2", fig2),
171
- # # ("3", fig3), # texttemplate not supported
172
- # ("4", fig4),
173
- # ("5", fig5),
174
- # ("6", fig6),
169
+ ("1", fig1),
170
+ ("2", fig2),
171
+ # ("3", fig3), # texttemplate not supported
172
+ ("4", fig4),
173
+ ("5", fig5),
174
+ ("6", fig6),
175
175
  ("7", fig7),
176
- # # ("8", fig8), # Not supported
177
- # ("9", fig9),
178
- # ("11", fig11)
176
+ # ("8", fig8), # Not supported
177
+ ("9", fig9),
178
+ ("11", fig11)
179
179
  ]
180
180
 
181
181
  main_tex_content = tex_create_document(options="twocolumn", compatibility="newest")