tikzplotly 0.1.5__tar.gz → 0.1.6__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.
- {tikzplotly-0.1.5 → tikzplotly-0.1.6}/PKG-INFO +4 -2
- {tikzplotly-0.1.5 → tikzplotly-0.1.6}/README.md +3 -0
- {tikzplotly-0.1.5 → tikzplotly-0.1.6}/pyproject.toml +1 -2
- {tikzplotly-0.1.5 → tikzplotly-0.1.6}/src/tests/test_heatmaps.py +9 -13
- {tikzplotly-0.1.5 → tikzplotly-0.1.6}/src/tests/test_markers.py +0 -1
- tikzplotly-0.1.6/src/tikzplotly/__about__.py +1 -0
- {tikzplotly-0.1.5 → tikzplotly-0.1.6}/src/tikzplotly/_heatmap.py +2 -2
- {tikzplotly-0.1.5 → tikzplotly-0.1.6}/src/tikzplotly/_save.py +7 -4
- {tikzplotly-0.1.5 → tikzplotly-0.1.6}/src/tikzplotly.egg-info/PKG-INFO +4 -2
- {tikzplotly-0.1.5 → tikzplotly-0.1.6}/src/tikzplotly.egg-info/SOURCES.txt +4 -1
- tikzplotly-0.1.6/tests/test_heatmap.py +65 -0
- tikzplotly-0.1.6/tests/test_markers.py +89 -0
- tikzplotly-0.1.6/tests/test_scatter.py +152 -0
- tikzplotly-0.1.5/src/tikzplotly/__about__.py +0 -1
- {tikzplotly-0.1.5 → tikzplotly-0.1.6}/LICENSE +0 -0
- {tikzplotly-0.1.5 → tikzplotly-0.1.6}/setup.cfg +0 -0
- {tikzplotly-0.1.5 → tikzplotly-0.1.6}/src/tests/test_line_charts.py +0 -0
- {tikzplotly-0.1.5 → tikzplotly-0.1.6}/src/tikzplotly/__init__.py +0 -0
- {tikzplotly-0.1.5 → tikzplotly-0.1.6}/src/tikzplotly/_annotations.py +0 -0
- {tikzplotly-0.1.5 → tikzplotly-0.1.6}/src/tikzplotly/_axis.py +0 -0
- {tikzplotly-0.1.5 → tikzplotly-0.1.6}/src/tikzplotly/_color.py +0 -0
- {tikzplotly-0.1.5 → tikzplotly-0.1.6}/src/tikzplotly/_dash.py +0 -0
- {tikzplotly-0.1.5 → tikzplotly-0.1.6}/src/tikzplotly/_data.py +0 -0
- {tikzplotly-0.1.5 → tikzplotly-0.1.6}/src/tikzplotly/_dataContainer.py +0 -0
- {tikzplotly-0.1.5 → tikzplotly-0.1.6}/src/tikzplotly/_marker.py +0 -0
- {tikzplotly-0.1.5 → tikzplotly-0.1.6}/src/tikzplotly/_scatter.py +0 -0
- {tikzplotly-0.1.5 → tikzplotly-0.1.6}/src/tikzplotly/_tex.py +0 -0
- {tikzplotly-0.1.5 → tikzplotly-0.1.6}/src/tikzplotly/_utils.py +0 -0
- {tikzplotly-0.1.5 → tikzplotly-0.1.6}/src/tikzplotly.egg-info/dependency_links.txt +0 -0
- {tikzplotly-0.1.5 → tikzplotly-0.1.6}/src/tikzplotly.egg-info/requires.txt +0 -0
- {tikzplotly-0.1.5 → tikzplotly-0.1.6}/src/tikzplotly.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: tikzplotly
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.6
|
|
4
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)
|
|
@@ -30,7 +30,6 @@ 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.7
|
|
34
33
|
Classifier: Programming Language :: Python :: 3.8
|
|
35
34
|
Classifier: Programming Language :: Python :: 3.9
|
|
36
35
|
Classifier: Programming Language :: Python :: 3.10
|
|
@@ -52,6 +51,9 @@ Requires-Dist: pandas; extra == "dev"
|
|
|
52
51
|
[](https://pypi.org/pypi/tikzplotly/)
|
|
53
52
|
|
|
54
53
|
[](https://github.com/thomas-saigre/tikzplotly/issues)
|
|
54
|
+
[](https://codecov.io/gh/thomas-saigre/tikzplotly)
|
|
55
|
+

|
|
56
|
+
|
|
55
57
|
|
|
56
58
|
# Tikzplotly
|
|
57
59
|
|
|
@@ -4,6 +4,9 @@
|
|
|
4
4
|
[](https://pypi.org/pypi/tikzplotly/)
|
|
5
5
|
|
|
6
6
|
[](https://github.com/thomas-saigre/tikzplotly/issues)
|
|
7
|
+
[](https://codecov.io/gh/thomas-saigre/tikzplotly)
|
|
8
|
+

|
|
9
|
+
|
|
7
10
|
|
|
8
11
|
# Tikzplotly
|
|
9
12
|
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "tikzplotly"
|
|
7
|
-
version = "0.1.
|
|
7
|
+
version = "0.1.6"
|
|
8
8
|
description = "Convert plotly figures to LaTeX / tikz figures"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
authors = [{name = "Thomas Saigre", email = "tikzplotly@outlook.fr"}]
|
|
@@ -13,7 +13,6 @@ classifiers = [
|
|
|
13
13
|
"Development Status :: 5 - Production/Stable",
|
|
14
14
|
"Programming Language :: Python",
|
|
15
15
|
"Programming Language :: Python :: 3",
|
|
16
|
-
"Programming Language :: Python :: 3.7",
|
|
17
16
|
"Programming Language :: Python :: 3.8",
|
|
18
17
|
"Programming Language :: Python :: 3.9",
|
|
19
18
|
"Programming Language :: Python :: 3.10",
|
|
@@ -6,11 +6,9 @@ from tikzplotly._tex import tex_create_document, tex_begin_environment, tex_end_
|
|
|
6
6
|
|
|
7
7
|
import plotly
|
|
8
8
|
import plotly.express as px
|
|
9
|
-
import pandas as pd
|
|
10
9
|
import plotly.graph_objects as go
|
|
11
10
|
import numpy as np
|
|
12
11
|
import datetime
|
|
13
|
-
import numpy as np
|
|
14
12
|
np.random.seed(1)
|
|
15
13
|
|
|
16
14
|
def fig1():
|
|
@@ -168,17 +166,16 @@ if __name__ == "__main__":
|
|
|
168
166
|
file_directory = os.path.dirname(os.path.abspath(__file__))
|
|
169
167
|
|
|
170
168
|
functions = [
|
|
171
|
-
("1", fig1),
|
|
172
|
-
("2", fig2),
|
|
173
|
-
# ("3", fig3), # texttemplate not supported
|
|
174
|
-
("4", fig4),
|
|
175
|
-
("5", fig5),
|
|
176
|
-
("6", fig6),
|
|
169
|
+
# ("1", fig1),
|
|
170
|
+
# ("2", fig2),
|
|
171
|
+
# # ("3", fig3), # texttemplate not supported
|
|
172
|
+
# ("4", fig4),
|
|
173
|
+
# ("5", fig5),
|
|
174
|
+
# ("6", fig6),
|
|
177
175
|
("7", fig7),
|
|
178
|
-
# ("8", fig8), # Not supported
|
|
179
|
-
("9", fig9),
|
|
180
|
-
("11", fig11)
|
|
181
|
-
|
|
176
|
+
# # ("8", fig8), # Not supported
|
|
177
|
+
# ("9", fig9),
|
|
178
|
+
# ("11", fig11)
|
|
182
179
|
]
|
|
183
180
|
|
|
184
181
|
main_tex_content = tex_create_document(options="twocolumn", compatibility="newest")
|
|
@@ -190,7 +187,6 @@ if __name__ == "__main__":
|
|
|
190
187
|
for i, f in functions:
|
|
191
188
|
print(f"Figure {i}")
|
|
192
189
|
fig, title = f()
|
|
193
|
-
data = fig.data
|
|
194
190
|
save_path = os.path.join(file_directory, "outputs", "test_heatmap", "fig{}.tex".format(i))
|
|
195
191
|
tikzplotly.save(save_path, fig, img_name=os.path.join(file_directory, "outputs", "test_heatmap", "fig{}.png".format(i)))
|
|
196
192
|
main_tex_content += tex_begin_environment("figure", stack_env)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.1.6"
|
|
@@ -131,8 +131,8 @@ def draw_heatmap(data, fig, img_name, axis: Axis):
|
|
|
131
131
|
axis.add_option("colormap", get_tikz_colorscale(DEFAULT_COLORSCALE))
|
|
132
132
|
|
|
133
133
|
tmp = np.where(figure_data == None, np.nan, figure_data)
|
|
134
|
-
axis.add_option("point meta max",
|
|
135
|
-
axis.add_option("point meta min",
|
|
134
|
+
axis.add_option("point meta max", np.nanmax(tmp))
|
|
135
|
+
axis.add_option("point meta min", np.nanmin(tmp))
|
|
136
136
|
axis.add_option("xmin", xmin)
|
|
137
137
|
axis.add_option("xmax", xmax)
|
|
138
138
|
axis.add_option("ymin", ymax)
|
|
@@ -78,13 +78,16 @@ def get_tikz_code(
|
|
|
78
78
|
if include_disclamer:
|
|
79
79
|
code += tex_comment(f"This file was created with tikzplotly version {__version__}.")
|
|
80
80
|
|
|
81
|
-
|
|
82
|
-
|
|
81
|
+
if len(data_container.data) > 0:
|
|
82
|
+
code += data_container.exportData()
|
|
83
|
+
code += "\n"
|
|
83
84
|
|
|
84
85
|
code += tex_begin_environment("tikzpicture", stack_env, options=tikz_options)
|
|
85
86
|
|
|
86
87
|
code += "\n"
|
|
87
|
-
|
|
88
|
+
color_list = list(colors_set)
|
|
89
|
+
color_list.sort()
|
|
90
|
+
for color in color_list:
|
|
88
91
|
code += tex_add_color(color[0], color[1], color[2])
|
|
89
92
|
code += "\n"
|
|
90
93
|
|
|
@@ -107,7 +110,7 @@ def get_tikz_code(
|
|
|
107
110
|
return code
|
|
108
111
|
|
|
109
112
|
|
|
110
|
-
def save(filepath
|
|
113
|
+
def save(filepath, *args, **kwargs):
|
|
111
114
|
"""Save a figure to a file or a stream.
|
|
112
115
|
|
|
113
116
|
Parameters
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: tikzplotly
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.6
|
|
4
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)
|
|
@@ -30,7 +30,6 @@ 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.7
|
|
34
33
|
Classifier: Programming Language :: Python :: 3.8
|
|
35
34
|
Classifier: Programming Language :: Python :: 3.9
|
|
36
35
|
Classifier: Programming Language :: Python :: 3.10
|
|
@@ -52,6 +51,9 @@ Requires-Dist: pandas; extra == "dev"
|
|
|
52
51
|
[](https://pypi.org/pypi/tikzplotly/)
|
|
53
52
|
|
|
54
53
|
[](https://github.com/thomas-saigre/tikzplotly/issues)
|
|
54
|
+
[](https://codecov.io/gh/thomas-saigre/tikzplotly)
|
|
55
|
+

|
|
56
|
+
|
|
55
57
|
|
|
56
58
|
# Tikzplotly
|
|
57
59
|
|
|
@@ -22,4 +22,7 @@ src/tikzplotly.egg-info/PKG-INFO
|
|
|
22
22
|
src/tikzplotly.egg-info/SOURCES.txt
|
|
23
23
|
src/tikzplotly.egg-info/dependency_links.txt
|
|
24
24
|
src/tikzplotly.egg-info/requires.txt
|
|
25
|
-
src/tikzplotly.egg-info/top_level.txt
|
|
25
|
+
src/tikzplotly.egg-info/top_level.txt
|
|
26
|
+
tests/test_heatmap.py
|
|
27
|
+
tests/test_markers.py
|
|
28
|
+
tests/test_scatter.py
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import plotly.express as px
|
|
2
|
+
import plotly.graph_objects as go
|
|
3
|
+
import numpy as np
|
|
4
|
+
import os
|
|
5
|
+
from .helpers import assert_equality
|
|
6
|
+
import pathlib
|
|
7
|
+
import datetime
|
|
8
|
+
|
|
9
|
+
this_dir = pathlib.Path(__file__).resolve().parent
|
|
10
|
+
test_name = "test_heatmap"
|
|
11
|
+
pathlib.Path("/tmp/tikzplotly").mkdir(parents=True, exist_ok=True)
|
|
12
|
+
|
|
13
|
+
def plot_1():
|
|
14
|
+
fig = px.imshow([[1, 20, 30],
|
|
15
|
+
[20, 1, 60],
|
|
16
|
+
[30, 60, 1]])
|
|
17
|
+
return fig
|
|
18
|
+
|
|
19
|
+
def plot_2():
|
|
20
|
+
df = px.data.medals_wide(indexed=True)
|
|
21
|
+
fig = px.imshow(df)
|
|
22
|
+
return fig
|
|
23
|
+
|
|
24
|
+
def plot_3():
|
|
25
|
+
fig = go.Figure(data=go.Heatmap(
|
|
26
|
+
z=[[1, None, 30, 50, 1], [20, 1, 60, 80, 30], [30, 60, 1, -10, 20]],
|
|
27
|
+
x=['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday'],
|
|
28
|
+
y=['Morning', 'Afternoon', 'Evening'],
|
|
29
|
+
hoverongaps = False))
|
|
30
|
+
return fig
|
|
31
|
+
|
|
32
|
+
def plot_4():
|
|
33
|
+
import plotly.graph_objects as go
|
|
34
|
+
|
|
35
|
+
programmers = ['Alex','Nicole','Sara','Etienne','Chelsea','Jody','Marianne']
|
|
36
|
+
|
|
37
|
+
base = datetime.datetime(2021, 7, 20, 19, 30, 0)
|
|
38
|
+
dates = base - np.arange(180) * datetime.timedelta(days=1)
|
|
39
|
+
np.random.seed(43)
|
|
40
|
+
z = np.random.poisson(size=(len(programmers), len(dates)))
|
|
41
|
+
|
|
42
|
+
fig = go.Figure(data=go.Heatmap(
|
|
43
|
+
z=z,
|
|
44
|
+
x=dates,
|
|
45
|
+
y=programmers,
|
|
46
|
+
colorscale='Viridis'))
|
|
47
|
+
|
|
48
|
+
fig.update_layout(
|
|
49
|
+
title='GitHub commits per day',
|
|
50
|
+
xaxis_nticks=36)
|
|
51
|
+
|
|
52
|
+
return fig
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def test_1():
|
|
56
|
+
assert_equality(plot_1(), os.path.join(this_dir, test_name, test_name + "_1_reference.tex"), img_name="/tmp/tikzplotly/fig1.png")
|
|
57
|
+
|
|
58
|
+
def test_2():
|
|
59
|
+
assert_equality(plot_2(), os.path.join(this_dir, test_name, test_name + "_2_reference.tex"), img_name="/tmp/tikzplotly/fig2.png")
|
|
60
|
+
|
|
61
|
+
def test_3():
|
|
62
|
+
assert_equality(plot_3(), os.path.join(this_dir, test_name, test_name + "_3_reference.tex"), img_name="/tmp/tikzplotly/fig3.png")
|
|
63
|
+
|
|
64
|
+
def test_4():
|
|
65
|
+
assert_equality(plot_4(), os.path.join(this_dir, test_name, test_name + "_4_reference.tex"), img_name="/tmp/tikzplotly/fig4.png")
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import plotly.express as px
|
|
2
|
+
import plotly.graph_objects as go
|
|
3
|
+
import numpy as np
|
|
4
|
+
import os
|
|
5
|
+
from .helpers import assert_equality
|
|
6
|
+
import pathlib
|
|
7
|
+
|
|
8
|
+
this_dir = pathlib.Path(__file__).resolve().parent
|
|
9
|
+
test_name = "test_markers"
|
|
10
|
+
|
|
11
|
+
def plot_1():
|
|
12
|
+
|
|
13
|
+
df = px.data.iris()
|
|
14
|
+
fig = px.scatter(df, x="sepal_width", y="sepal_length", color="species")
|
|
15
|
+
|
|
16
|
+
fig.update_traces(marker=dict(size=12,
|
|
17
|
+
line=dict(width=2,
|
|
18
|
+
color='DarkSlateGrey')),
|
|
19
|
+
selector=dict(mode='markers'))
|
|
20
|
+
return fig
|
|
21
|
+
|
|
22
|
+
def plot_2():
|
|
23
|
+
np.random.seed(1)
|
|
24
|
+
x = np.random.uniform(low=3, high=6, size=(500,))
|
|
25
|
+
y = np.random.uniform(low=3, high=6, size=(500,))
|
|
26
|
+
|
|
27
|
+
# Build figure
|
|
28
|
+
fig = go.Figure()
|
|
29
|
+
|
|
30
|
+
# Add scatter trace with medium sized markers
|
|
31
|
+
fig.add_trace(
|
|
32
|
+
go.Scatter(
|
|
33
|
+
mode='markers',
|
|
34
|
+
x=x,
|
|
35
|
+
y=y,
|
|
36
|
+
marker=dict(
|
|
37
|
+
color='LightSkyBlue',
|
|
38
|
+
size=20,
|
|
39
|
+
opacity=0.5,
|
|
40
|
+
line=dict(
|
|
41
|
+
color='MediumPurple',
|
|
42
|
+
width=2
|
|
43
|
+
)
|
|
44
|
+
),
|
|
45
|
+
showlegend=False
|
|
46
|
+
)
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
# Add trace with large markers
|
|
51
|
+
fig.add_trace(
|
|
52
|
+
go.Scatter(
|
|
53
|
+
mode='markers',
|
|
54
|
+
x=[2, 2],
|
|
55
|
+
y=[4.25, 4.75],
|
|
56
|
+
marker=dict(
|
|
57
|
+
color='LightSkyBlue',
|
|
58
|
+
size=80,
|
|
59
|
+
opacity=0.5,
|
|
60
|
+
line=dict(
|
|
61
|
+
color='MediumPurple',
|
|
62
|
+
width=8
|
|
63
|
+
)
|
|
64
|
+
),
|
|
65
|
+
showlegend=False
|
|
66
|
+
)
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
return fig
|
|
70
|
+
|
|
71
|
+
def plot_3():
|
|
72
|
+
df = px.data.iris()
|
|
73
|
+
fig = px.scatter(df, x="sepal_width", y="sepal_length", color="species")
|
|
74
|
+
|
|
75
|
+
fig.update_traces(
|
|
76
|
+
marker=dict(size=8, symbol="diamond", line=dict(width=2, color="DarkSlateGrey")),
|
|
77
|
+
selector=dict(mode="markers"),
|
|
78
|
+
)
|
|
79
|
+
|
|
80
|
+
return fig
|
|
81
|
+
|
|
82
|
+
def test_1():
|
|
83
|
+
assert_equality(plot_1(), os.path.join(this_dir, test_name, test_name + "_1_reference.tex"))
|
|
84
|
+
|
|
85
|
+
def test_2():
|
|
86
|
+
assert_equality(plot_2(), os.path.join(this_dir, test_name, test_name + "_2_reference.tex"))
|
|
87
|
+
|
|
88
|
+
def test_3():
|
|
89
|
+
assert_equality(plot_3(), os.path.join(this_dir, test_name, test_name + "_3_reference.tex"))
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import plotly.express as px
|
|
2
|
+
import plotly.graph_objects as go
|
|
3
|
+
import numpy as np
|
|
4
|
+
import os
|
|
5
|
+
from .helpers import assert_equality
|
|
6
|
+
import pathlib
|
|
7
|
+
|
|
8
|
+
this_dir = pathlib.Path(__file__).resolve().parent
|
|
9
|
+
test_name = "test_scatter"
|
|
10
|
+
|
|
11
|
+
def plot_1():
|
|
12
|
+
df = px.data.gapminder().query("continent == 'Oceania'")
|
|
13
|
+
fig = px.line(df, x='year', y='lifeExp', color='country', markers=True)
|
|
14
|
+
return fig
|
|
15
|
+
|
|
16
|
+
def plot_2():
|
|
17
|
+
df = px.data.gapminder().query("country in ['Canada', 'Botswana']")
|
|
18
|
+
fig = px.line(df, x="lifeExp", y="gdpPercap", color="country", text="year")
|
|
19
|
+
fig.update_traces(textposition="bottom right")
|
|
20
|
+
|
|
21
|
+
# fig.show()
|
|
22
|
+
return fig
|
|
23
|
+
|
|
24
|
+
def plot_3():
|
|
25
|
+
x = np.arange(10)
|
|
26
|
+
fig = go.Figure(data=go.Scatter(x=x, y=x**2))
|
|
27
|
+
return fig
|
|
28
|
+
|
|
29
|
+
def plot_4():
|
|
30
|
+
labels = ['Television', 'Newspaper', 'Internet', 'Radio']
|
|
31
|
+
colors = ['rgb(67,67,67)', 'rgb(115,115,115)', 'rgb(49,130,189)', 'rgb(189,189,189)']
|
|
32
|
+
|
|
33
|
+
mode_size = [4, 4, 6, 4]
|
|
34
|
+
line_size = [2, 2, 4, 2]
|
|
35
|
+
|
|
36
|
+
x_data = np.vstack((np.arange(2001, 2013),)*4)
|
|
37
|
+
|
|
38
|
+
y_data = np.array([
|
|
39
|
+
[74, 82, 80, 74, 73, 72, 74, 70, 70, 66, 66, 69],
|
|
40
|
+
[45, 42, 50, 46, 36, 36, 34, 35, 32, 31, 31, 28],
|
|
41
|
+
[13, 14, 20, 24, 20, 24, 24, 40, 35, 41, 43, 50],
|
|
42
|
+
[18, 21, 18, 21, 16, 14, 13, 18, 17, 16, 19, 23],
|
|
43
|
+
])
|
|
44
|
+
|
|
45
|
+
fig = go.Figure()
|
|
46
|
+
|
|
47
|
+
for i in range(0, 4):
|
|
48
|
+
fig.add_trace(go.Scatter(x=x_data[i], y=y_data[i], mode='lines',
|
|
49
|
+
name=labels[i],
|
|
50
|
+
line=dict(color=colors[i], width=line_size[i]),
|
|
51
|
+
connectgaps=True,
|
|
52
|
+
))
|
|
53
|
+
|
|
54
|
+
# endpoints
|
|
55
|
+
fig.add_trace(go.Scatter(
|
|
56
|
+
x=[x_data[i][0], x_data[i][-1]],
|
|
57
|
+
y=[y_data[i][0], y_data[i][-1]],
|
|
58
|
+
mode='markers',
|
|
59
|
+
marker=dict(color=colors[i], size=mode_size[i])
|
|
60
|
+
))
|
|
61
|
+
|
|
62
|
+
fig.update_layout(
|
|
63
|
+
xaxis=dict(
|
|
64
|
+
showline=True,
|
|
65
|
+
showgrid=False,
|
|
66
|
+
showticklabels=True,
|
|
67
|
+
linecolor='rgb(204, 204, 204)',
|
|
68
|
+
linewidth=2,
|
|
69
|
+
ticks='outside',
|
|
70
|
+
tickfont=dict(
|
|
71
|
+
family='Arial',
|
|
72
|
+
size=12,
|
|
73
|
+
color='rgb(82, 82, 82)',
|
|
74
|
+
),
|
|
75
|
+
),
|
|
76
|
+
yaxis=dict(
|
|
77
|
+
showgrid=False,
|
|
78
|
+
zeroline=False,
|
|
79
|
+
showline=False,
|
|
80
|
+
showticklabels=False,
|
|
81
|
+
),
|
|
82
|
+
autosize=False,
|
|
83
|
+
margin=dict(
|
|
84
|
+
autoexpand=False,
|
|
85
|
+
l=100,
|
|
86
|
+
r=20,
|
|
87
|
+
t=110,
|
|
88
|
+
),
|
|
89
|
+
showlegend=False,
|
|
90
|
+
plot_bgcolor='white'
|
|
91
|
+
)
|
|
92
|
+
|
|
93
|
+
annotations = []
|
|
94
|
+
|
|
95
|
+
# Adding labels
|
|
96
|
+
for y_trace, label, color in zip(y_data, labels, colors):
|
|
97
|
+
# labeling the left_side of the plot
|
|
98
|
+
annotations.append(dict(xref='paper', x=0.05, y=y_trace[0],
|
|
99
|
+
xanchor='right', yanchor='middle',
|
|
100
|
+
text=label + ' {}%'.format(y_trace[0]),
|
|
101
|
+
font=dict(family='Arial',
|
|
102
|
+
size=16),
|
|
103
|
+
showarrow=False))
|
|
104
|
+
# labeling the right_side of the plot
|
|
105
|
+
annotations.append(dict(xref='paper', x=0.95, y=y_trace[11],
|
|
106
|
+
xanchor='left', yanchor='middle',
|
|
107
|
+
text='{}%'.format(y_trace[11]),
|
|
108
|
+
font=dict(family='Arial',
|
|
109
|
+
size=16),
|
|
110
|
+
showarrow=False))
|
|
111
|
+
# Title
|
|
112
|
+
annotations.append(dict(xref='paper', yref='paper', x=0.0, y=1.05,
|
|
113
|
+
xanchor='left', yanchor='bottom',
|
|
114
|
+
text='Main Source for News',
|
|
115
|
+
font=dict(family='Arial',
|
|
116
|
+
size=30,
|
|
117
|
+
color='rgb(37,37,37)'),
|
|
118
|
+
showarrow=False))
|
|
119
|
+
# Source
|
|
120
|
+
annotations.append(dict(xref='paper', yref='paper', x=0.5, y=-0.1,
|
|
121
|
+
xanchor='center', yanchor='top',
|
|
122
|
+
text='Source: PewResearch Center & ' +
|
|
123
|
+
'Storytelling with data',
|
|
124
|
+
font=dict(family='Arial',
|
|
125
|
+
size=12,
|
|
126
|
+
color='rgb(150,150,150)'),
|
|
127
|
+
showarrow=False))
|
|
128
|
+
|
|
129
|
+
fig.update_layout(annotations=annotations)
|
|
130
|
+
|
|
131
|
+
# fig.show()
|
|
132
|
+
return fig
|
|
133
|
+
|
|
134
|
+
def plot_5():
|
|
135
|
+
df = px.data.stocks()
|
|
136
|
+
fig = px.line(df, x='date', y="GOOG")
|
|
137
|
+
return fig
|
|
138
|
+
|
|
139
|
+
def test_1():
|
|
140
|
+
assert_equality(plot_1(), os.path.join(this_dir, test_name, test_name + "_1_reference.tex"))
|
|
141
|
+
|
|
142
|
+
def test_2():
|
|
143
|
+
assert_equality(plot_2(), os.path.join(this_dir, test_name, test_name + "_2_reference.tex"))
|
|
144
|
+
|
|
145
|
+
def test_3():
|
|
146
|
+
assert_equality(plot_3(), os.path.join(this_dir, test_name, test_name + "_3_reference.tex"))
|
|
147
|
+
|
|
148
|
+
def test_4():
|
|
149
|
+
assert_equality(plot_4(), os.path.join(this_dir, test_name, test_name + "_4_reference.tex"))
|
|
150
|
+
|
|
151
|
+
def test_5():
|
|
152
|
+
assert_equality(plot_5(), os.path.join(this_dir, test_name, test_name + "_5_reference.tex"))
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.1.4"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|