From 02c2fbf06c36b8bd36db137554b1a799f592aca6 Mon Sep 17 00:00:00 2001 From: Thomas Saigre Date: Mon, 13 May 2024 16:50:25 +0200 Subject: [PATCH 1/9] begin to set up tests with tox #12 --- .gitignore | 5 ++ src/tests/README.md | 3 + src/tests/test_heatmaps.py | 2 - src/tikzplotly/_save.py | 4 +- tests/__init__.py | 0 tests/helpers.py | 21 ++++++ tests/test_scatter.py | 36 ++++++++++ .../test_scatter_1_reference.tikz | 30 ++++++++ .../test_scatter_2_reference.tikz | 68 +++++++++++++++++++ .../test_scatter_3_reference.tikz | 20 ++++++ tox.ini | 15 ++++ 11 files changed, 201 insertions(+), 3 deletions(-) create mode 100644 tests/__init__.py create mode 100644 tests/helpers.py create mode 100644 tests/test_scatter.py create mode 100644 tests/test_scatter/test_scatter_1_reference.tikz create mode 100644 tests/test_scatter/test_scatter_2_reference.tikz create mode 100644 tests/test_scatter/test_scatter_3_reference.tikz create mode 100644 tox.ini diff --git a/.gitignore b/.gitignore index 8222173..492809b 100644 --- a/.gitignore +++ b/.gitignore @@ -20,3 +20,8 @@ venv/ # Distribution / packaging dist/ + +# Tox +.tox/ +.coverage +coverage.xml \ No newline at end of file diff --git a/src/tests/README.md b/src/tests/README.md index b2a0dfb..cc242f4 100644 --- a/src/tests/README.md +++ b/src/tests/README.md @@ -1,5 +1,8 @@ # Run test +This tests are only for devlopment purposes. +Automatic tests are set-up in [../tests](../tests/) directory. + ```bash python3 -m tests. ``` \ No newline at end of file diff --git a/src/tests/test_heatmaps.py b/src/tests/test_heatmaps.py index d659d9e..af1572e 100644 --- a/src/tests/test_heatmaps.py +++ b/src/tests/test_heatmaps.py @@ -178,7 +178,6 @@ def fig11(): # from @JasonGross, see issue https://github.com/thomas-saigre/t # ("8", fig8), # Not supported ("9", fig9), ("11", fig11) - ] main_tex_content = tex_create_document(options="twocolumn", compatibility="newest") @@ -190,7 +189,6 @@ def fig11(): # from @JasonGross, see issue https://github.com/thomas-saigre/t for i, f in functions: print(f"Figure {i}") fig, title = f() - data = fig.data save_path = os.path.join(file_directory, "outputs", "test_heatmap", "fig{}.tex".format(i)) tikzplotly.save(save_path, fig, img_name=os.path.join(file_directory, "outputs", "test_heatmap", "fig{}.png".format(i))) main_tex_content += tex_begin_environment("figure", stack_env) diff --git a/src/tikzplotly/_save.py b/src/tikzplotly/_save.py index 5174ac0..3d0d960 100755 --- a/src/tikzplotly/_save.py +++ b/src/tikzplotly/_save.py @@ -84,7 +84,9 @@ def get_tikz_code( code += tex_begin_environment("tikzpicture", stack_env, options=tikz_options) code += "\n" - for color in colors_set: + color_list = list(colors_set) + color_list.sort() + for color in color_list: code += tex_add_color(color[0], color[1], color[2]) code += "\n" diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/helpers.py b/tests/helpers.py new file mode 100644 index 0000000..658d997 --- /dev/null +++ b/tests/helpers.py @@ -0,0 +1,21 @@ +# Adapted from https://github.com/nschloe/tikzplotlib/blob/450712b4014799ec5f151f234df84335c90f4b9d/tests/helpers.py + +import tikzplotly + + +# https://stackoverflow.com/a/845432/353337 +def _unidiff_output(expected, actual): + import difflib + + expected = expected.splitlines(1) + actual = actual.splitlines(1) + diff = difflib.unified_diff(expected, actual) + return "".join(diff) + +def assert_equality(fig, target_file, **kwargs): + tikz_code = tikzplotly.get_tikz_code(fig, include_disclamer=False, **kwargs) + + + with open(this_dir / target_file, encoding="utf-8") as f: + reference = f.read() + assert reference == tikz_code, target_file + "\n" + _unidiff_output(reference, tikz_code) diff --git a/tests/test_scatter.py b/tests/test_scatter.py new file mode 100644 index 0000000..5823d76 --- /dev/null +++ b/tests/test_scatter.py @@ -0,0 +1,36 @@ +import plotly.express as px +import plotly.graph_objects as go +import numpy as np +import os +from .helpers import assert_equality +import pathlib + +this_dir = pathlib.Path(__file__).resolve().parent +test_name = "test_scatter" + +def plot_1(): + df = px.data.gapminder().query("continent == 'Oceania'") + fig = px.line(df, x='year', y='lifeExp', color='country', markers=True) + return fig + +def plot_2(): + df = px.data.gapminder().query("country in ['Canada', 'Botswana']") + fig = px.line(df, x="lifeExp", y="gdpPercap", color="country", text="year") + fig.update_traces(textposition="bottom right") + + # fig.show() + return fig + +def plot_3(): + x = np.arange(10) + fig = go.Figure(data=go.Scatter(x=x, y=x**2)) + return fig + +def test_1(): + assert_equality(plot_1(), os.path.join(this_dir, test_name, test_name + "_1_reference.tikz")) + +def test_2(): + assert_equality(plot_2(), os.path.join(this_dir, test_name, test_name + "_2_reference.tikz")) + +def test_3(): + assert_equality(plot_3(), os.path.join(this_dir, test_name, test_name + "_3_reference.tikz")) \ No newline at end of file diff --git a/tests/test_scatter/test_scatter_1_reference.tikz b/tests/test_scatter/test_scatter_1_reference.tikz new file mode 100644 index 0000000..28af129 --- /dev/null +++ b/tests/test_scatter/test_scatter_1_reference.tikz @@ -0,0 +1,30 @@ +\pgfplotstableread{data0 Australia New_Zealand +1952 69.12 69.39 +1957 70.33 70.26 +1962 70.93 71.24 +1967 71.1 71.52 +1972 71.93 71.89 +1977 73.49 72.22 +1982 74.74 73.84 +1987 76.32 74.32 +1992 77.56 76.33 +1997 78.83 77.55 +2002 80.37 79.11 +2007 81.235 80.204 +}\dataZ + +\begin{tikzpicture} + +\definecolor{636efa}{HTML}{636efa} +\definecolor{EF553B}{HTML}{EF553B} + +\begin{axis}[ +xlabel=year, +ylabel=lifeExp +] +\addplot+ [mark=*, solid, color=636efa] table[y=Australia] {\dataZ}; +\addlegendentry{Australia} +\addplot+ [mark=*, solid, color=EF553B] table[y=New_Zealand] {\dataZ}; +\addlegendentry{New Zealand} +\end{axis} +\end{tikzpicture} diff --git a/tests/test_scatter/test_scatter_2_reference.tikz b/tests/test_scatter/test_scatter_2_reference.tikz new file mode 100644 index 0000000..a430911 --- /dev/null +++ b/tests/test_scatter/test_scatter_2_reference.tikz @@ -0,0 +1,68 @@ +\pgfplotstableread{data0 Botswana +47.622 851.2411407 +49.618 918.2325349 +51.52 983.6539764 +53.298 1214.709294 +56.024 2263.6111140000007 +59.319 3214.857818 +61.484 4551.14215 +63.622 6205.88385 +62.745 7954.111645 +52.556 8647.142313 +46.63399999999999 11003.60508 +50.728 12569.85177 +}\dataZ +\pgfplotstableread{data1 Canada +68.75 11367.16112 +69.96 12489.95006 +71.3 13462.48555 +72.13 16076.58803 +72.88 18970.57086 +74.21 22090.88306 +75.76 22898.79214 +76.86 26626.51503 +77.95 26342.88426 +78.61 28954.92589 +79.77 33328.96507 +80.653 36319.23501 +}\dataO + +\begin{tikzpicture} + +\definecolor{636efa}{HTML}{636efa} +\definecolor{EF553B}{HTML}{EF553B} + +\begin{axis}[ +xlabel=lifeExp, +ylabel=gdpPercap +] +\addplot+ [mark=*, solid, color=636efa] table[y=Botswana] {\dataZ}; +\node at (axis cs:47.622,851.2411407) {1952}; +\node at (axis cs:49.618,918.2325349) {1957}; +\node at (axis cs:51.52,983.6539764) {1962}; +\node at (axis cs:53.298,1214.709294) {1967}; +\node at (axis cs:56.024,2263.6111140000007) {1972}; +\node at (axis cs:59.319,3214.857818) {1977}; +\node at (axis cs:61.484,4551.14215) {1982}; +\node at (axis cs:63.622,6205.88385) {1987}; +\node at (axis cs:62.745,7954.111645) {1992}; +\node at (axis cs:52.556,8647.142313) {1997}; +\node at (axis cs:46.63399999999999,11003.60508) {2002}; +\node at (axis cs:50.728,12569.85177) {2007}; +\addlegendentry{Botswana} +\addplot+ [mark=*, solid, color=EF553B] table[y=Canada] {\dataO}; +\node at (axis cs:68.75,11367.16112) {1952}; +\node at (axis cs:69.96,12489.95006) {1957}; +\node at (axis cs:71.3,13462.48555) {1962}; +\node at (axis cs:72.13,16076.58803) {1967}; +\node at (axis cs:72.88,18970.57086) {1972}; +\node at (axis cs:74.21,22090.88306) {1977}; +\node at (axis cs:75.76,22898.79214) {1982}; +\node at (axis cs:76.86,26626.51503) {1987}; +\node at (axis cs:77.95,26342.88426) {1992}; +\node at (axis cs:78.61,28954.92589) {1997}; +\node at (axis cs:79.77,33328.96507) {2002}; +\node at (axis cs:80.653,36319.23501) {2007}; +\addlegendentry{Canada} +\end{axis} +\end{tikzpicture} diff --git a/tests/test_scatter/test_scatter_3_reference.tikz b/tests/test_scatter/test_scatter_3_reference.tikz new file mode 100644 index 0000000..63d211f --- /dev/null +++ b/tests/test_scatter/test_scatter_3_reference.tikz @@ -0,0 +1,20 @@ +\pgfplotstableread{data0 y0 +0 0 +1 1 +2 4 +3 9 +4 16 +5 25 +6 36 +7 49 +8 64 +9 81 +}\dataZ + +\begin{tikzpicture} + + +\begin{axis} +\addplot+ table[y=y0] {\dataZ}; +\end{axis} +\end{tikzpicture} diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..d8109fb --- /dev/null +++ b/tox.ini @@ -0,0 +1,15 @@ +[tox] +envlist = + py3 +isolated_build = True + +[testenv] +deps = + pandas + pytest + pytest-cov + pytest-codeblocks + plotly + pytest-randomly +commands = + pytest {posargs} \ No newline at end of file From 156f04b5e9b03d3bdd4edb9a393ec7cc7db2ac8e Mon Sep 17 00:00:00 2001 From: Thomas Saigre Date: Tue, 14 May 2024 17:05:18 +0200 Subject: [PATCH 2/9] up more tests #12 --- src/tests/test_heatmaps.py | 20 +- src/tests/test_markers.py | 1 - src/tikzplotly/_heatmap.py | 4 +- src/tikzplotly/_save.py | 5 +- tests/helpers.py | 3 +- tests/test_heatmap.py | 65 +++ .../test_heatmap/test_heatmap_1_reference.tex | 30 + .../test_heatmap/test_heatmap_2_reference.tex | 36 ++ .../test_heatmap/test_heatmap_3_reference.tex | 33 ++ .../test_heatmap/test_heatmap_4_reference.tex | 34 ++ tests/test_markers.py | 89 +++ .../test_markers/test_markers_1_reference.tex | 176 ++++++ .../test_markers/test_markers_2_reference.tex | 517 ++++++++++++++++++ .../test_markers/test_markers_3_reference.tex | 176 ++++++ tests/test_scatter.py | 122 ++++- ...ence.tikz => test_scatter_1_reference.tex} | 0 ...ence.tikz => test_scatter_2_reference.tex} | 0 ...ence.tikz => test_scatter_3_reference.tex} | 0 .../test_scatter/test_scatter_4_reference.tex | 53 ++ .../test_scatter/test_scatter_5_reference.tex | 120 ++++ tox.ini | 1 + 21 files changed, 1464 insertions(+), 21 deletions(-) create mode 100644 tests/test_heatmap.py create mode 100644 tests/test_heatmap/test_heatmap_1_reference.tex create mode 100644 tests/test_heatmap/test_heatmap_2_reference.tex create mode 100644 tests/test_heatmap/test_heatmap_3_reference.tex create mode 100644 tests/test_heatmap/test_heatmap_4_reference.tex create mode 100644 tests/test_markers.py create mode 100644 tests/test_markers/test_markers_1_reference.tex create mode 100644 tests/test_markers/test_markers_2_reference.tex create mode 100644 tests/test_markers/test_markers_3_reference.tex rename tests/test_scatter/{test_scatter_1_reference.tikz => test_scatter_1_reference.tex} (100%) rename tests/test_scatter/{test_scatter_2_reference.tikz => test_scatter_2_reference.tex} (100%) rename tests/test_scatter/{test_scatter_3_reference.tikz => test_scatter_3_reference.tex} (100%) create mode 100644 tests/test_scatter/test_scatter_4_reference.tex create mode 100644 tests/test_scatter/test_scatter_5_reference.tex diff --git a/src/tests/test_heatmaps.py b/src/tests/test_heatmaps.py index af1572e..83d22f0 100644 --- a/src/tests/test_heatmaps.py +++ b/src/tests/test_heatmaps.py @@ -6,11 +6,9 @@ import plotly import plotly.express as px -import pandas as pd import plotly.graph_objects as go import numpy as np import datetime -import numpy as np np.random.seed(1) def fig1(): @@ -168,16 +166,16 @@ def fig11(): # from @JasonGross, see issue https://github.com/thomas-saigre/t file_directory = os.path.dirname(os.path.abspath(__file__)) functions = [ - ("1", fig1), - ("2", fig2), - # ("3", fig3), # texttemplate not supported - ("4", fig4), - ("5", fig5), - ("6", fig6), + # ("1", fig1), + # ("2", fig2), + # # ("3", fig3), # texttemplate not supported + # ("4", fig4), + # ("5", fig5), + # ("6", fig6), ("7", fig7), - # ("8", fig8), # Not supported - ("9", fig9), - ("11", fig11) + # # ("8", fig8), # Not supported + # ("9", fig9), + # ("11", fig11) ] main_tex_content = tex_create_document(options="twocolumn", compatibility="newest") diff --git a/src/tests/test_markers.py b/src/tests/test_markers.py index bf371b9..cc68770 100644 --- a/src/tests/test_markers.py +++ b/src/tests/test_markers.py @@ -1,7 +1,6 @@ # From https://plotly.com/python/marker-style/ import plotly import plotly.express as px -import pandas as pd import plotly.graph_objects as go import numpy as np import tikzplotly diff --git a/src/tikzplotly/_heatmap.py b/src/tikzplotly/_heatmap.py index 5b4a150..70e704f 100755 --- a/src/tikzplotly/_heatmap.py +++ b/src/tikzplotly/_heatmap.py @@ -131,8 +131,8 @@ def draw_heatmap(data, fig, img_name, axis: Axis): axis.add_option("colormap", get_tikz_colorscale(DEFAULT_COLORSCALE)) tmp = np.where(figure_data == None, np.nan, figure_data) - axis.add_option("point meta max", tmp.max()) - axis.add_option("point meta min", tmp.min()) + axis.add_option("point meta max", np.nanmax(tmp)) + axis.add_option("point meta min", np.nanmin(tmp)) axis.add_option("xmin", xmin) axis.add_option("xmax", xmax) axis.add_option("ymin", ymax) diff --git a/src/tikzplotly/_save.py b/src/tikzplotly/_save.py index 3d0d960..13e6eef 100755 --- a/src/tikzplotly/_save.py +++ b/src/tikzplotly/_save.py @@ -78,8 +78,9 @@ def get_tikz_code( if include_disclamer: code += tex_comment(f"This file was created with tikzplotly version {__version__}.") - code += data_container.exportData() - code += "\n" + if len(data_container.data) > 0: + code += data_container.exportData() + code += "\n" code += tex_begin_environment("tikzpicture", stack_env, options=tikz_options) diff --git a/tests/helpers.py b/tests/helpers.py index 658d997..bb10777 100644 --- a/tests/helpers.py +++ b/tests/helpers.py @@ -15,7 +15,6 @@ def _unidiff_output(expected, actual): def assert_equality(fig, target_file, **kwargs): tikz_code = tikzplotly.get_tikz_code(fig, include_disclamer=False, **kwargs) - - with open(this_dir / target_file, encoding="utf-8") as f: + with open(target_file, encoding="utf-8") as f: reference = f.read() assert reference == tikz_code, target_file + "\n" + _unidiff_output(reference, tikz_code) diff --git a/tests/test_heatmap.py b/tests/test_heatmap.py new file mode 100644 index 0000000..fb04949 --- /dev/null +++ b/tests/test_heatmap.py @@ -0,0 +1,65 @@ +import plotly.express as px +import plotly.graph_objects as go +import numpy as np +import os +from .helpers import assert_equality +import pathlib +import datetime + +this_dir = pathlib.Path(__file__).resolve().parent +test_name = "test_heatmap" +pathlib.Path("/tmp/tikzplotly").mkdir(parents=True, exist_ok=True) + +def plot_1(): + fig = px.imshow([[1, 20, 30], + [20, 1, 60], + [30, 60, 1]]) + return fig + +def plot_2(): + df = px.data.medals_wide(indexed=True) + fig = px.imshow(df) + return fig + +def plot_3(): + fig = go.Figure(data=go.Heatmap( + z=[[1, None, 30, 50, 1], [20, 1, 60, 80, 30], [30, 60, 1, -10, 20]], + x=['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday'], + y=['Morning', 'Afternoon', 'Evening'], + hoverongaps = False)) + return fig + +def plot_4(): + import plotly.graph_objects as go + + programmers = ['Alex','Nicole','Sara','Etienne','Chelsea','Jody','Marianne'] + + base = datetime.datetime(2021, 7, 20, 19, 30, 0) + dates = base - np.arange(180) * datetime.timedelta(days=1) + np.random.seed(43) + z = np.random.poisson(size=(len(programmers), len(dates))) + + fig = go.Figure(data=go.Heatmap( + z=z, + x=dates, + y=programmers, + colorscale='Viridis')) + + fig.update_layout( + title='GitHub commits per day', + xaxis_nticks=36) + + return fig + + +def test_1(): + assert_equality(plot_1(), os.path.join(this_dir, test_name, test_name + "_1_reference.tex"), img_name="/tmp/tikzplotly/fig1.png") + +def test_2(): + assert_equality(plot_2(), os.path.join(this_dir, test_name, test_name + "_2_reference.tex"), img_name="/tmp/tikzplotly/fig2.png") + +def test_3(): + assert_equality(plot_3(), os.path.join(this_dir, test_name, test_name + "_3_reference.tex"), img_name="/tmp/tikzplotly/fig3.png") + +def test_4(): + assert_equality(plot_4(), os.path.join(this_dir, test_name, test_name + "_4_reference.tex"), img_name="/tmp/tikzplotly/fig4.png") \ No newline at end of file diff --git a/tests/test_heatmap/test_heatmap_1_reference.tex b/tests/test_heatmap/test_heatmap_1_reference.tex new file mode 100644 index 0000000..c48de4e --- /dev/null +++ b/tests/test_heatmap/test_heatmap_1_reference.tex @@ -0,0 +1,30 @@ +\begin{tikzpicture} + + +\begin{axis}[ +y dir=reverse, +colorbar, +colormap={mycolor}{ +rgb255(0.0cm)=(13,8,135); +rgb255(0.1111111111111111cm)=(70,3,159); +rgb255(0.2222222222222222cm)=(114,1,168); +rgb255(0.3333333333333333cm)=(156,23,158); +rgb255(0.4444444444444444cm)=(189,55,134); +rgb255(0.5555555555555556cm)=(216,87,107); +rgb255(0.6666666666666666cm)=(237,121,83); +rgb255(0.7777777777777778cm)=(251,159,58); +rgb255(0.8888888888888888cm)=(253,202,38); +rgb255(1.0cm)=(240,249,33); +}, +point meta max=60.0, +point meta min=1.0, +xmin=-0.5, +xmax=2.5, +ymin=-0.5, +ymax=2.5, +tick align=outside, +tick pos=left +] +\addplot+ graphics[includegraphics cmd=\pgfimage,xmin=-0.5, xmax=2.5, ymin=2.5, ymax=-0.5] {/tmp/tikzplotly/fig1.png}; +\end{axis} +\end{tikzpicture} diff --git a/tests/test_heatmap/test_heatmap_2_reference.tex b/tests/test_heatmap/test_heatmap_2_reference.tex new file mode 100644 index 0000000..ae4b133 --- /dev/null +++ b/tests/test_heatmap/test_heatmap_2_reference.tex @@ -0,0 +1,36 @@ +\begin{tikzpicture} + + +\begin{axis}[ +y dir=reverse, +colorbar, +xtick={0,1,2}, +xticklabels={gold,silver,bronze}, +ytick={0,1,2}, +yticklabels={South Korea,China,Canada}, +colormap={mycolor}{ +rgb255(0.0cm)=(13,8,135); +rgb255(0.1111111111111111cm)=(70,3,159); +rgb255(0.2222222222222222cm)=(114,1,168); +rgb255(0.3333333333333333cm)=(156,23,158); +rgb255(0.4444444444444444cm)=(189,55,134); +rgb255(0.5555555555555556cm)=(216,87,107); +rgb255(0.6666666666666666cm)=(237,121,83); +rgb255(0.7777777777777778cm)=(251,159,58); +rgb255(0.8888888888888888cm)=(253,202,38); +rgb255(1.0cm)=(240,249,33); +}, +point meta max=24.0, +point meta min=8.0, +xmin=-0.5, +xmax=2.5, +ymin=-0.5, +ymax=2.5, +tick align=outside, +tick pos=left, +xlabel=medal, +ylabel=nation +] +\addplot+ graphics[includegraphics cmd=\pgfimage,xmin=-0.5, xmax=2.5, ymin=2.5, ymax=-0.5] {/tmp/tikzplotly/fig2.png}; +\end{axis} +\end{tikzpicture} diff --git a/tests/test_heatmap/test_heatmap_3_reference.tex b/tests/test_heatmap/test_heatmap_3_reference.tex new file mode 100644 index 0000000..2766ca4 --- /dev/null +++ b/tests/test_heatmap/test_heatmap_3_reference.tex @@ -0,0 +1,33 @@ +\begin{tikzpicture} + + +\begin{axis}[ +colorbar, +xtick={0,1,2,3,4}, +xticklabels={Monday,Tuesday,Wednesday,Thursday,Friday}, +ytick={0,1,2}, +yticklabels={Morning,Afternoon,Evening}, +colormap={mycolor}{ +rgb255(0.0cm)=(13,8,135); +rgb255(0.1111111111111111cm)=(70,3,159); +rgb255(0.2222222222222222cm)=(114,1,168); +rgb255(0.3333333333333333cm)=(156,23,158); +rgb255(0.4444444444444444cm)=(189,55,134); +rgb255(0.5555555555555556cm)=(216,87,107); +rgb255(0.6666666666666666cm)=(237,121,83); +rgb255(0.7777777777777778cm)=(251,159,58); +rgb255(0.8888888888888888cm)=(253,202,38); +rgb255(1.0cm)=(240,249,33); +}, +point meta max=80, +point meta min=-10, +xmin=-0.5, +xmax=4.5, +ymin=-0.5, +ymax=2.5, +tick align=outside, +tick pos=left +] +\addplot+ graphics[includegraphics cmd=\pgfimage,xmin=-0.5, xmax=4.5, ymin=2.5, ymax=-0.5] {/tmp/tikzplotly/fig3.png}; +\end{axis} +\end{tikzpicture} diff --git a/tests/test_heatmap/test_heatmap_4_reference.tex b/tests/test_heatmap/test_heatmap_4_reference.tex new file mode 100644 index 0000000..852c690 --- /dev/null +++ b/tests/test_heatmap/test_heatmap_4_reference.tex @@ -0,0 +1,34 @@ +\begin{tikzpicture} + + +\begin{axis}[ +colorbar, +xtick={0,5,10,15,20,25,30,35,40,45,50,55,60,65,70,75,80,85,90,95,100,105,110,115,120,125,130,135,140,145,150,155,160,165,170,175,179}, +xticklabels={2021-07-20 19:30:00,2021-07-15 19:30:00,2021-07-10 19:30:00,2021-07-05 19:30:00,2021-06-30 19:30:00,2021-06-25 19:30:00,2021-06-20 19:30:00,2021-06-15 19:30:00,2021-06-10 19:30:00,2021-06-05 19:30:00,2021-05-31 19:30:00,2021-05-26 19:30:00,2021-05-21 19:30:00,2021-05-16 19:30:00,2021-05-11 19:30:00,2021-05-06 19:30:00,2021-05-01 19:30:00,2021-04-26 19:30:00,2021-04-21 19:30:00,2021-04-16 19:30:00,2021-04-11 19:30:00,2021-04-06 19:30:00,2021-04-01 19:30:00,2021-03-27 19:30:00,2021-03-22 19:30:00,2021-03-17 19:30:00,2021-03-12 19:30:00,2021-03-07 19:30:00,2021-03-02 19:30:00,2021-02-25 19:30:00,2021-02-20 19:30:00,2021-02-15 19:30:00,2021-02-10 19:30:00,2021-02-05 19:30:00,2021-01-31 19:30:00,2021-01-26 19:30:00,2021-01-22 19:30:00}, +ytick={0,1,2,3,4,5,6}, +yticklabels={Alex,Nicole,Sara,Etienne,Chelsea,Jody,Marianne}, +colormap={mycolor}{ +rgb255(0.0cm)=(68,1,84); +rgb255(0.1111111111111111cm)=(72,40,120); +rgb255(0.2222222222222222cm)=(62,73,137); +rgb255(0.3333333333333333cm)=(49,104,142); +rgb255(0.4444444444444444cm)=(38,130,142); +rgb255(0.5555555555555556cm)=(31,158,137); +rgb255(0.6666666666666666cm)=(53,183,121); +rgb255(0.7777777777777778cm)=(110,206,88); +rgb255(0.8888888888888888cm)=(181,222,43); +rgb255(1.0cm)=(253,231,37); +}, +point meta max=6.0, +point meta min=0.0, +xmin=-0.5, +xmax=179.5, +ymin=-0.5, +ymax=6.5, +tick align=outside, +tick pos=left, +title=GitHub commits per day +] +\addplot+ graphics[includegraphics cmd=\pgfimage,xmin=-0.5, xmax=179.5, ymin=6.5, ymax=-0.5] {/tmp/tikzplotly/fig4.png}; +\end{axis} +\end{tikzpicture} diff --git a/tests/test_markers.py b/tests/test_markers.py new file mode 100644 index 0000000..53ce202 --- /dev/null +++ b/tests/test_markers.py @@ -0,0 +1,89 @@ +import plotly.express as px +import plotly.graph_objects as go +import numpy as np +import os +from .helpers import assert_equality +import pathlib + +this_dir = pathlib.Path(__file__).resolve().parent +test_name = "test_markers" + +def plot_1(): + + df = px.data.iris() + fig = px.scatter(df, x="sepal_width", y="sepal_length", color="species") + + fig.update_traces(marker=dict(size=12, + line=dict(width=2, + color='DarkSlateGrey')), + selector=dict(mode='markers')) + return fig + +def plot_2(): + np.random.seed(1) + x = np.random.uniform(low=3, high=6, size=(500,)) + y = np.random.uniform(low=3, high=6, size=(500,)) + + # Build figure + fig = go.Figure() + + # Add scatter trace with medium sized markers + fig.add_trace( + go.Scatter( + mode='markers', + x=x, + y=y, + marker=dict( + color='LightSkyBlue', + size=20, + opacity=0.5, + line=dict( + color='MediumPurple', + width=2 + ) + ), + showlegend=False + ) + ) + + + # Add trace with large markers + fig.add_trace( + go.Scatter( + mode='markers', + x=[2, 2], + y=[4.25, 4.75], + marker=dict( + color='LightSkyBlue', + size=80, + opacity=0.5, + line=dict( + color='MediumPurple', + width=8 + ) + ), + showlegend=False + ) + ) + + return fig + +def plot_3(): + df = px.data.iris() + fig = px.scatter(df, x="sepal_width", y="sepal_length", color="species") + + fig.update_traces( + marker=dict(size=8, symbol="diamond", line=dict(width=2, color="DarkSlateGrey")), + selector=dict(mode="markers"), + ) + + return fig + +def test_1(): + assert_equality(plot_1(), os.path.join(this_dir, test_name, test_name + "_1_reference.tex")) + +def test_2(): + assert_equality(plot_2(), os.path.join(this_dir, test_name, test_name + "_2_reference.tex")) + +def test_3(): + assert_equality(plot_3(), os.path.join(this_dir, test_name, test_name + "_3_reference.tex")) \ No newline at end of file diff --git a/tests/test_markers/test_markers_1_reference.tex b/tests/test_markers/test_markers_1_reference.tex new file mode 100644 index 0000000..1bd63e4 --- /dev/null +++ b/tests/test_markers/test_markers_1_reference.tex @@ -0,0 +1,176 @@ +\pgfplotstableread{data0 setosa +3.5 5.1 +3.0 4.9 +3.2 4.7 +3.1 4.6 +3.6 5.0 +3.9 5.4 +3.4 4.6 +3.4 5.0 +2.9 4.4 +3.1 4.9 +3.7 5.4 +3.4 4.8 +3.0 4.8 +3.0 4.3 +4.0 5.8 +4.4 5.7 +3.9 5.4 +3.5 5.1 +3.8 5.7 +3.8 5.1 +3.4 5.4 +3.7 5.1 +3.6 4.6 +3.3 5.1 +3.4 4.8 +3.0 5.0 +3.4 5.0 +3.5 5.2 +3.4 5.2 +3.2 4.7 +3.1 4.8 +3.4 5.4 +4.1 5.2 +4.2 5.5 +3.1 4.9 +3.2 5.0 +3.5 5.5 +3.1 4.9 +3.0 4.4 +3.4 5.1 +3.5 5.0 +2.3 4.5 +3.2 4.4 +3.5 5.0 +3.8 5.1 +3.0 4.8 +3.8 5.1 +3.2 4.6 +3.7 5.3 +3.3 5.0 +}\dataZ +\pgfplotstableread{data1 versicolor +3.2 7.0 +3.2 6.4 +3.1 6.9 +2.3 5.5 +2.8 6.5 +2.8 5.7 +3.3 6.3 +2.4 4.9 +2.9 6.6 +2.7 5.2 +2.0 5.0 +3.0 5.9 +2.2 6.0 +2.9 6.1 +2.9 5.6 +3.1 6.7 +3.0 5.6 +2.7 5.8 +2.2 6.2 +2.5 5.6 +3.2 5.9 +2.8 6.1 +2.5 6.3 +2.8 6.1 +2.9 6.4 +3.0 6.6 +2.8 6.8 +3.0 6.7 +2.9 6.0 +2.6 5.7 +2.4 5.5 +2.4 5.5 +2.7 5.8 +2.7 6.0 +3.0 5.4 +3.4 6.0 +3.1 6.7 +2.3 6.3 +3.0 5.6 +2.5 5.5 +2.6 5.5 +3.0 6.1 +2.6 5.8 +2.3 5.0 +2.7 5.6 +3.0 5.7 +2.9 5.7 +2.9 6.2 +2.5 5.1 +2.8 5.7 +}\dataO +\pgfplotstableread{data2 virginica +3.3 6.3 +2.7 5.8 +3.0 7.1 +2.9 6.3 +3.0 6.5 +3.0 7.6 +2.5 4.9 +2.9 7.3 +2.5 6.7 +3.6 7.2 +3.2 6.5 +2.7 6.4 +3.0 6.8 +2.5 5.7 +2.8 5.8 +3.2 6.4 +3.0 6.5 +3.8 7.7 +2.6 7.7 +2.2 6.0 +3.2 6.9 +2.8 5.6 +2.8 7.7 +2.7 6.3 +3.3 6.7 +3.2 7.2 +2.8 6.2 +3.0 6.1 +2.8 6.4 +3.0 7.2 +2.8 7.4 +3.8 7.9 +2.8 6.4 +2.8 6.3 +2.6 6.1 +3.0 7.7 +3.4 6.3 +3.1 6.4 +3.0 6.0 +3.1 6.9 +3.1 6.7 +3.1 6.9 +2.7 5.8 +3.2 6.8 +3.3 6.7 +3.0 6.7 +2.5 6.3 +3.0 6.5 +3.4 6.2 +3.0 5.9 +}\dataT + +\begin{tikzpicture} + +\definecolor{00cc96}{HTML}{00cc96} +\definecolor{636efa}{HTML}{636efa} +\definecolor{EF553B}{HTML}{EF553B} +\definecolor{darkslategrey}{RGB}{47, 79, 79} + +\begin{axis}[ +xlabel=sepal\_width, +ylabel=sepal\_length +] +\addplot+ [mark=*, only marks, mark size=9, mark options={solid, fill=636efa, draw=darkslategrey, line width=1.5}] table[y=setosa] {\dataZ}; +\addlegendentry{setosa} +\addplot+ [mark=*, only marks, mark size=9, mark options={solid, fill=EF553B, draw=darkslategrey, line width=1.5}] table[y=versicolor] {\dataO}; +\addlegendentry{versicolor} +\addplot+ [mark=*, only marks, mark size=9, mark options={solid, fill=00cc96, draw=darkslategrey, line width=1.5}] table[y=virginica] {\dataT}; +\addlegendentry{virginica} +\end{axis} +\end{tikzpicture} diff --git a/tests/test_markers/test_markers_2_reference.tex b/tests/test_markers/test_markers_2_reference.tex new file mode 100644 index 0000000..fa2e092 --- /dev/null +++ b/tests/test_markers/test_markers_2_reference.tex @@ -0,0 +1,517 @@ +\pgfplotstableread{data0 y0 +4.251066014107722 3.2624466286607725 +5.160973480326474 3.6819292088540663 +3.0003431244520344 3.943129848342151 +3.9069977178955195 3.5242976290689345 +3.440267672451339 4.821282485917381 +3.2770157843063936 4.240759245003484 +3.558780634133013 5.449054535481642 +4.036682181129143 3.555391194807092 +4.19030242269201 5.105629589268931 +4.616450202010071 3.7210668745474167 +4.2575835432098845 4.722657266522579 +5.055658501190278 4.0469627916623665 +3.613356749194552 3.170893198448498 +5.6343523091728365 3.6864410128811276 +3.0821627795937783 4.992307666064381 +5.011402530535207 4.491750280081594 +4.251914407101381 4.557047952221036 +4.676069485337255 3.5241604503267676 +3.421160815785701 4.7121475546387686 +3.5943044672546365 5.99026027562463 +5.40223370602661 5.4505053263748655 +5.904784727158193 4.783117871492934 +3.9402725344777285 5.927967204992715 +5.076967847007943 5.7046877540079635 +5.629167456888115 4.7868238008079365 +5.683819990511542 3.097278975943371 +3.2551326341093336 3.280731287452442 +3.117164349698647 3.1961151451266794 +3.5094912586937066 4.355199446074426 +5.634427510288239 4.126304499503574 +3.2950405014991504 5.926050102810859 +4.263322875015156 3.503949879598845 +5.873668590451506 5.9183627757979655 +4.599495854919051 5.302424606589039 +5.07563134185142 5.472713518873493 +3.946546893018189 4.897847450333992 +5.059502783044751 5.006198310620196 +5.503877015692119 4.43064700056358 +3.0548648320325755 3.0394090707692167 +5.250432944834902 4.059018256625475 +5.966583266719484 4.4762154044806755 +5.244496963139518 5.190273633270313 +3.8413319761932154 4.405885028238328 +5.367837985354465 4.372214748268295 +3.3096780197329263 3.4129882228368094 +4.3436805785277155 3.032666201410437 +5.725786509279287 5.274834781430989 +3.8808424451210386 3.9598585142330354 +3.8633260157590463 5.9531503505805325 +3.3900857163548332 3.660702678477468 +3.0581008736108912 4.016124076445039 +5.036506598819673 4.571688406998395 +3.634884348000177 5.264674371181599 +3.7966399781166786 4.391573351700886 +4.474719477841015 3.3744676293350286 +3.1600876353512413 3.9375041354761486 +4.7223528164760395 4.513557509102984 +3.4401857247174306 5.021547024050603 +4.767916610709853 5.310449868936276 +5.099275080062793 3.391007342863063 +3.3070032864834777 3.0687453939671454 +4.242167963458705 4.557246966635969 +5.083200473183235 5.429966131987249 +4.242537808580708 3.037811301089629 +3.1498603768382614 5.017409533961201 +4.607689217746534 5.060424679970975 +4.991383935659366 4.347740260759913 +4.544667336174926 5.744366060225802 +5.83378426797244 4.933083254270979 +4.759665121505979 3.0157195129543974 +5.71020574586365 4.453285336543127 +3.4124241124387127 5.5779534182928 +3.4178290417522756 5.491198710112018 +5.422173866128571 4.947462591337434 +4.193030510956601 5.021095271695895 +3.4960625913507983 4.735498739367602 +5.782525741188102 3.8223593255005563 +4.043297579236519 4.681589971608176 +5.252436309408466 5.015189354452261 +5.177993956051354 4.057288890649227 +5.64991827361743 5.5674851017617835 +4.871016621166826 3.585112458026122 +5.252827302082012 5.24196243099577 +4.046695025933527 3.868808238560632 +3.809783675295078 5.321397861732546 +5.6876586545882 4.283211988008229 +4.284273569613885 5.423095227336629 +5.894520141445157 4.060604588003971 +4.990324493455344 3.6410797128887435 +4.865087160627366 5.301853525265299 +3.3442379188601254 3.9259258428919535 +5.848467776121214 5.199735203179283 +4.349736400439822 5.233419459233197 +4.735168843161395 3.664190102724603 +4.224410408283843 3.6423364104619456 +3.711080940729083 3.5968437702812 +5.710138561686762 3.427555013297534 +4.721038460016858 4.131247797622002 +3.0086109810934767 3.079883654074864 +4.851434740862172 3.332761107102722 +3.9799347053162886 5.023692071290231 +4.581174306772828 5.399329610692159 +5.657826297932323 3.241588581385158 +4.0718092800075 3.695106931457376 +5.725605452759398 3.622876985411443 +4.870080347375408 5.752000689244892 +3.047463728539669 5.13394355440946 +5.788311701231284 4.661653833154243 +5.072690752550772 3.913553963761861 +5.991968551354441 5.504562142895395 +3.5170215250359855 4.30591787288856 +3.411407248886633 5.770368645356326 +5.797786389111491 5.118155413007799 +5.090454484469701 4.43409392389585 +3.1980005181661877 3.378630311248076 +5.266389157807399 5.928130651403243 +5.261628565383739 3.4795009510322803 +5.76907360663945 3.6078063756589875 +5.134574275885415 4.293545265481113 +3.372812885916494 4.212605717325442 +3.0596404015193865 3.4402544422928822 +3.0786329606331577 5.18795675808337 +3.084919464062384 3.566235200631558 +3.7386332028091376 4.931686932934989 +5.580083846048664 5.262917851728896 +4.616493193024958 3.6321971762499623 +4.658465936057297 4.80286274432292 +5.526092677078817 5.246785125737509 +3.372519945359733 4.914656131861 +3.8375510370334185 4.791381908839947 +4.757277814374864 3.886446856966491 +5.908787244959024 5.1948194137245265 +4.68309065776713 5.835925319999849 +3.055941868118829 4.276684170784641 +5.401898018041849 5.346545450494216 +3.698922821523061 3.168423118985746 +5.421315586856338 5.505814807469898 +4.163581932192516 3.576750050466443 +5.590625563678286 4.18529060666992 +5.241364928211554 3.9002431377760693 +4.668720701971257 3.240310931418148 +3.409365676982055 5.7138930088087285 +3.179753068536635 4.110462532661215 +3.3640303672222123 4.592092315428419 +3.1336556356342853 4.482348797688975 +3.3224823873182787 3.3964834258288144 +3.677128015823564 3.6193621766682993 +5.1389669411480305 3.2285664270969634 +4.679150946162427 4.523765099835862 +3.0376679404773475 3.7846486554989616 +3.2159228390684604 4.071184826648375 +5.901828990000816 3.3241959860917105 +4.704301385759827 5.362655518957522 +3.6098797039829713 3.319751630366403 +3.75697723371097 5.9571264711395635 +5.231477562225279 3.531483493315252 +3.5862884433279563 4.717215337303948 +4.744076781819773 3.1345360037672645 +5.910059967264937 5.361348868967502 +5.540486404470106 3.5688178434548896 +3.7195432774427584 4.58371193522438 +4.4813091428061895 5.220232629477215 +4.859867155144139 3.4497944547517676 +5.486942698650536 4.653261522560915 +3.4703741839382527 3.649851624986338 +3.0557286065322287 5.277588147951434 +3.210066431157667 5.1687455806686415 +4.459035332811095 3.529647102831249 +4.818988384959991 5.5858996730012205 +4.706554311259444 3.059325298549033 +3.9520872279664823 5.580710992269346 +5.9658484632373465 4.676711433482815 +4.739235657737391 4.209661416317548 +4.140423517870651 5.27624079306701 +4.652844657353691 5.15078700507741 +5.236003292719506 5.961978524425279 +5.007698680359554 3.834255145838948 +3.7947586729884284 3.011381017228028 +3.199004503285325 5.801707824944663 +4.110252593742318 5.573691313613681 +4.889152521064693 5.186552632557768 +3.630522029744519 4.550066348764615 +5.2582666612164415 5.120868735746283 +3.199609444062345 5.3415886706302285 +3.7809452957356227 4.124627830610578 +5.414263691230037 5.3109675759898725 +3.580302847869983 5.251872957525526 +4.91838264263982 4.839633634632779 +4.5740109273712015 4.205597771903513 +5.774423911198053 5.0919240577930225 +3.789890311461333 3.0093385734755764 +3.1978832720520716 5.324689940173793 +5.2051978898660085 5.68924980737054 +5.316534088629741 3.717947122312514 +5.723447557510572 3.362301552927689 +5.795916207590512 3.660851963381183 +3.041854718926791 3.9062901938702947 +3.7030862583642614 5.649085525691502 +4.850335071004973 4.629499290714284 +5.84704896206285 3.860134948819292 +5.850528357741239 3.4150640693788397 +4.6699595645854695 3.870433389313625 +5.746819049298823 4.841613269223758 +4.924698626839012 3.97241558969234 +4.170023142423739 4.372080545072995 +4.457972001290729 4.332351321049844 +4.81293144875992 5.484406082194536 +4.648643764525688 4.279044462708692 +5.778544280119361 4.037096463526507 +5.756200306900818 5.024914814427316 +4.184626838770665 3.664446167200586 +5.889787585322136 4.401737471779661 +3.521867000041393 3.9442970619720494 +3.378988558318912 4.880566806488504 +3.405237474140194 5.632081424084438 +4.51698649703069 4.343067000436886 +3.064574415822594 5.353372256375769 +5.843910633653043 4.370897101684651 +5.481346413512197 4.968687995151394 +3.045056942226367 3.3955229250825063 +3.5285887667251656 4.298944520902944 +3.996190723100511 5.72793596596481 +3.3929905344327507 4.816437003092804 +5.428472076379746 5.300323761711306 +4.03420995804988 4.514101824287684 +5.820322447000102 4.494166874484023 +4.74604253984124 5.52869952057855 +5.636495953235532 3.203420803022861 +5.534203336176666 4.719816814649054 +5.716176956125947 5.828287726298848 +4.379640797450421 4.553580144516966 +4.63904044806112 3.5833974285836536 +5.395810773456118 5.5438181773304285 +3.857156555202443 3.7549174270675585 +4.470760567859783 5.102178109447614 +4.797330922937635 4.6207828211907 +3.046599826652507 5.846508864840659 +4.780444224589912 4.873010107208028 +4.301029046968375 5.513933886143188 +5.422081586654524 3.0237986285835694 +3.9457344092861186 5.968020168499914 +5.678666125575454 3.2331437109971595 +4.733571645853607 3.9663885408443087 +3.552030604882395 5.838457186370296 +5.363787701476513 3.026817307113735 +4.836093531134802 5.468190016265806 +3.161727816221259 5.583634915100383 +4.260581040003396 4.319492442625718 +5.037206509696289 3.7672355814177934 +5.755805333932578 5.408068558899895 +3.001206074674072 4.433586013296663 +5.930277447093179 3.4030158259670884 +4.129740944237323 5.783546978475032 +5.921350615074967 5.687909901019945 +4.81414830292216 4.4746354500508065 +5.486537423942079 5.570107489553377 +4.724134514124307 4.255734077292296 +4.884228594922051 5.050394700498903 +3.8567288450870816 4.193971918223768 +4.760500021968249 4.517226052352431 +5.25006529110798 3.568655108501782 +5.574941509287127 5.894966772332742 +5.26524656540304 3.882647064732764 +5.094171745341908 3.310378668349204 +5.5934382901638 3.4329462006871445 +3.9680429905102392 3.0422768825773288 +5.012366372362761 5.147837098387184 +4.3526218092400475 4.693494960722623 +4.146308256094551 5.383735053554257 +4.232434049766557 4.521239769852409 +4.204438750408622 5.375463118512462 +3.9521518378748306 5.087292642815518 +4.865758103760904 5.3335454305775265 +4.290741812463793 4.219448606931259 +5.921406233781757 4.943311899562444 +5.033402674302933 3.539382893078923 +3.5957096652813325 3.9654598901637117 +4.280103028044098 3.5178138603593774 +4.030038719323269 4.225911675039788 +5.392916411875699 3.7242562438967965 +5.639994865690295 4.220765982388073 +5.711525867479116 5.9256670273119365 +4.988159437125787 3.960957977466094 +3.8106247860892735 5.947472834924686 +3.757100104513769 4.90891837756795 +5.564693828092207 4.125273055181733 +4.58314393892624 5.572453497250789 +5.406483252013794 4.858760218105721 +4.7174655515748185 3.756099240392518 +5.199427575862533 5.378567033930663 +4.557034882392168 4.298815526202489 +5.312651731505664 4.072533501991324 +4.706573972114146 3.9908308095752427 +4.397129635775943 5.092106626839419 +4.028066723859846 3.8059503717186796 +3.2046280452501126 5.42483404111614 +4.133772537984299 3.8858663831995433 +3.238878233094757 4.6323641507560716 +5.948451341191335 4.463764475415607 +3.5448385539922915 5.56606923778611 +5.435576093161619 5.665159303186158 +5.624884934867694 3.5531533271033 +5.06523975715783 4.756045376814753 +4.708483238236127 5.694615138051411 +3.4829143104468265 4.3383516571032885 +4.400640068289919 5.765604916451446 +4.035516153465645 3.836972671370913 +3.6751198734422537 4.826493522581387 +4.77753560629739 5.047361129300446 +3.936809513105751 3.684617200051452 +5.748916660405053 3.0413025376731504 +5.728906574854671 4.250171887112089 +3.7713548813465887 5.815445675570202 +3.3326739022320875 4.029084329491219 +3.5788881960573384 5.3392328864478 +4.498752512036658 3.5242089384822224 +5.185757003923788 4.0258585089073575 +3.6245833152263742 3.43379316251429 +3.7441006751316923 5.1503124424391284 +5.555015624809101 5.097922871090443 +4.247546154802582 5.065491953846756 +4.850055201465708 3.760188103458899 +3.7009984177177504 5.077080364870227 +3.3059017782773923 3.681892622747849 +4.5475710509055896 4.273947347794019 +4.431422961149347 4.115766365003061 +3.4580149322794895 4.065923734860366 +4.865418695221246 3.172964421723769 +4.632030356441814 4.8949398805978195 +4.962412040912233 5.121949808045098 +3.4336366203739797 4.840766083508507 +5.254583451405732 4.9449382684893735 +3.666147419399768 3.5098221426517733 +4.558055473098099 3.4483403968165875 +5.355888084664857 4.542525130577649 +3.0669912839754185 5.625998179063617 +3.9730873791785593 3.551860324641666 +5.618767129200333 4.38851735612478 +5.534128822806209 4.286797002089709 +4.615321777783631 4.491867557758549 +5.599824822499539 3.484532311458036 +5.84941797406088 4.027321923404432 +5.479220992888024 3.7856412123105607 +5.562346331509616 5.533580829688437 +3.296230205461045 5.400996737329205 +4.953912997022973 4.279917474804431 +5.110550964457959 4.821046382367117 +4.8307224379398885 3.43639683079866 +5.398845785208084 4.528839882652676 +3.1037136596149026 3.8908412573607136 +5.31071620366494 5.578952860707603 +5.195185802218581 5.014795142719169 +3.779095179895059 4.900422037867263 +3.77120789646644 3.374253900207538 +4.896909952290383 4.411763638496657 +4.035892384773245 5.959718338760645 +5.3897660340218625 5.844897522217995 +4.338438696010372 4.935256920781331 +5.348248244352516 3.455174613095921 +5.971415350871522 4.917380546159714 +3.9007450186017003 4.696986337631783 +3.429017484774298 4.405997512983756 +5.703925309047822 4.284112408404811 +4.624678136662119 4.79780926697409 +5.924221112565247 5.549909665547896 +4.909813200005692 5.253363121115813 +5.981739073831436 4.738081620891699 +4.638212412428855 5.774112544608084 +4.579277801716564 3.1942199503246465 +3.4062837092165097 5.974039526195427 +4.067115512951643 3.1589836280039685 +3.0786557018891196 3.598486638415684 +3.481185538558947 4.268257984933683 +5.236911578122488 3.322526628555503 +3.0911990697863665 4.871011232993105 +4.099629291731233 3.143977692146602 +5.587038758514132 3.8538716430208266 +5.078033152522063 3.1831100433590134 +5.072826426198506 5.110557993315243 +3.5659104028659327 5.005368502768446 +4.32571284224527 4.135741779751807 +4.744732222032874 3.564582780089464 +5.9692551229911155 5.241014487089835 +3.6117186756993656 4.021137872296402 +3.7431987052870648 5.385903502216928 +3.786519251318736 4.463702817538861 +5.250517239893979 4.577008333052938 +4.370925982307078 3.0854725484747014 +3.1707883152332847 4.932696059637095 +4.525548721830718 4.051969507296502 +3.635880493931028 3.687615081876197 +5.39581273428063 4.301650128635101 +3.8919941445218167 4.147402371812753 +3.082818035863511 4.4093671202590805 +4.780297348393863 5.9384500625394185 +5.531521286793566 4.093134211104691 +4.143048372186643 5.323230400008118 +5.24957493217843 4.658302789649678 +4.533424434891384 5.667393267322448 +4.6228554148865655 4.064858553448715 +5.8783029631852575 3.736556040559522 +5.41188267449594 5.733057718970905 +3.096969199870722 3.1306027912732963 +5.1281617536938855 5.852260284183007 +4.395004444690518 4.669220747012776 +5.8426468241853 4.129089650061262 +3.664298202970465 5.985156967017334 +3.8012160590530972 3.175087938442895 +3.244421894631786 4.550119079302837 +4.28585648599136 3.0932912263666434 +3.327056292057205 4.713527217558701 +4.901360281835753 3.5414055269853466 +5.408889712121214 4.892877601018592 +5.090401488360536 5.942771027251744 +5.298634143227312 5.6247076536371425 +4.027362359530559 4.355508748262611 +5.537554449083033 5.125382610155151 +4.2863063249983275 5.3324062500095675 +5.472029611236956 4.484529252547691 +4.879488475872881 4.585600470532695 +3.4302691460107346 3.4523531951165776 +3.235160699564844 4.108199776835718 +3.054997928739022 3.4266637592183598 +3.200174992918069 5.180681260033688 +4.375751441125296 4.43103898320679 +3.3400257683027714 4.346636510120296 +3.08335004654601 5.657993913496053 +5.264584444171402 4.582856316934684 +4.1845514413819185 4.227272495750579 +5.240815486822576 3.8066760666379373 +4.357214480239355 3.2160361055093096 +4.3502602410022835 4.254408401175947 +4.434217520153493 3.07726044721975 +4.422011779686582 3.8734618216572843 +5.4094900263425085 4.510528529545189 +4.207177559573207 5.897799195059167 +5.714058481030869 3.328148742580754 +3.1111831438621076 5.019123162649866 +5.321623028161256 4.4997971132976 +3.3769241434132162 5.331294687827349 +4.855540700736256 3.430820993622628 +3.031092784005696 3.2496079093076267 +4.615881847729041 4.197655816057361 +3.009053869858789 5.3908867559397 +5.853581356470613 3.57502721672967 +5.716206101108334 5.303331576441822 +5.387900825826808 3.8708939911856044 +5.745822959744363 3.650674462835386 +3.436674693475191 3.0501467672310194 +3.4731902096116 4.195977179767136 +3.562895018707302 4.143244473880357 +4.867487706899763 4.978034808586094 +5.717428488024906 3.2127552014111616 +5.969865535077221 3.4578119611268154 +5.133367376297448 3.0497276487028024 +5.195401227426886 3.3413890693422204 +5.727879613632764 4.955367828030271 +4.202621197113363 4.207970556524757 +3.7495520406751104 3.9630789425019475 +3.5202905123613686 4.673735982731317 +3.358371151001187 5.98038138929955 +5.437831764098486 5.503459542054089 +3.4403771202517293 5.098869547198752 +3.792892448180702 5.754775767396174 +5.457267535900592 3.1191861200492546 +3.93176175538263 3.2110003248465757 +5.947252347878829 4.422018869964164 +3.799916106454906 4.047502238871232 +4.600960034913634 5.811756186385347 +3.943401033557549 4.468694883435505 +5.732318493521513 4.618947330280052 +4.099669931553703 5.685781097193662 +4.300776981819494 4.339905137471072 +4.536878076835084 5.631103167811055 +5.81665943210914 3.760745248114885 +3.092847018813452 3.8214291124743256 +5.150635990895068 3.9850841702627706 +5.673056862877017 4.64269281144286 +3.0818616705524065 3.6603860220809437 +4.566153741757532 5.01428751324382 +3.977969435310076 3.4283798484090013 +5.578467962596758 3.282300823498918 +4.675549652767554 5.610575238616133 +5.070683604488243 3.7106061106709953 +4.358560499854613 4.158012033067786 +4.884927112564071 4.714626278175997 +3.8702905550622777 4.57740590985441 +3.0280457338995475 3.2280716383263206 +4.730267804961272 5.622377806794085 +3.9343326423973886 5.853406855256076 +4.55180279550339 5.437521912524016 +5.749217559161693 3.851405504840623 +4.2794243655041875 4.583540388353878 +3.7421881098071563 4.018250172052829 +4.113881283837163 4.664001932363 +5.795583349909622 5.923210406739008 +5.8106051439272814 3.9351087531569444 +5.53298984569714 5.006389817768609 +5.760619542916981 3.9779016219269576 +3.6837008698539506 5.323431798045239 +}\dataZ +\pgfplotstableread{data1 y0 +2 4.25 +2 4.75 +}\dataO + +\begin{tikzpicture} + +\definecolor{lightskyblue}{RGB}{135, 206, 250} +\definecolor{mediumpurple}{RGB}{147, 112, 219} + +\begin{axis} +\addplot+ [only marks, mark size=15, mark options={solid, fill=lightskyblue, draw=mediumpurple, line width=1.5, opacity=0.5}, forget plot] table[y=y0] {\dataZ}; +\addplot+ [only marks, mark size=60, mark options={solid, fill=lightskyblue, draw=mediumpurple, line width=6, opacity=0.5}, forget plot] table[y=y0] {\dataO}; +\end{axis} +\end{tikzpicture} diff --git a/tests/test_markers/test_markers_3_reference.tex b/tests/test_markers/test_markers_3_reference.tex new file mode 100644 index 0000000..6ea2340 --- /dev/null +++ b/tests/test_markers/test_markers_3_reference.tex @@ -0,0 +1,176 @@ +\pgfplotstableread{data0 setosa +3.5 5.1 +3.0 4.9 +3.2 4.7 +3.1 4.6 +3.6 5.0 +3.9 5.4 +3.4 4.6 +3.4 5.0 +2.9 4.4 +3.1 4.9 +3.7 5.4 +3.4 4.8 +3.0 4.8 +3.0 4.3 +4.0 5.8 +4.4 5.7 +3.9 5.4 +3.5 5.1 +3.8 5.7 +3.8 5.1 +3.4 5.4 +3.7 5.1 +3.6 4.6 +3.3 5.1 +3.4 4.8 +3.0 5.0 +3.4 5.0 +3.5 5.2 +3.4 5.2 +3.2 4.7 +3.1 4.8 +3.4 5.4 +4.1 5.2 +4.2 5.5 +3.1 4.9 +3.2 5.0 +3.5 5.5 +3.1 4.9 +3.0 4.4 +3.4 5.1 +3.5 5.0 +2.3 4.5 +3.2 4.4 +3.5 5.0 +3.8 5.1 +3.0 4.8 +3.8 5.1 +3.2 4.6 +3.7 5.3 +3.3 5.0 +}\dataZ +\pgfplotstableread{data1 versicolor +3.2 7.0 +3.2 6.4 +3.1 6.9 +2.3 5.5 +2.8 6.5 +2.8 5.7 +3.3 6.3 +2.4 4.9 +2.9 6.6 +2.7 5.2 +2.0 5.0 +3.0 5.9 +2.2 6.0 +2.9 6.1 +2.9 5.6 +3.1 6.7 +3.0 5.6 +2.7 5.8 +2.2 6.2 +2.5 5.6 +3.2 5.9 +2.8 6.1 +2.5 6.3 +2.8 6.1 +2.9 6.4 +3.0 6.6 +2.8 6.8 +3.0 6.7 +2.9 6.0 +2.6 5.7 +2.4 5.5 +2.4 5.5 +2.7 5.8 +2.7 6.0 +3.0 5.4 +3.4 6.0 +3.1 6.7 +2.3 6.3 +3.0 5.6 +2.5 5.5 +2.6 5.5 +3.0 6.1 +2.6 5.8 +2.3 5.0 +2.7 5.6 +3.0 5.7 +2.9 5.7 +2.9 6.2 +2.5 5.1 +2.8 5.7 +}\dataO +\pgfplotstableread{data2 virginica +3.3 6.3 +2.7 5.8 +3.0 7.1 +2.9 6.3 +3.0 6.5 +3.0 7.6 +2.5 4.9 +2.9 7.3 +2.5 6.7 +3.6 7.2 +3.2 6.5 +2.7 6.4 +3.0 6.8 +2.5 5.7 +2.8 5.8 +3.2 6.4 +3.0 6.5 +3.8 7.7 +2.6 7.7 +2.2 6.0 +3.2 6.9 +2.8 5.6 +2.8 7.7 +2.7 6.3 +3.3 6.7 +3.2 7.2 +2.8 6.2 +3.0 6.1 +2.8 6.4 +3.0 7.2 +2.8 7.4 +3.8 7.9 +2.8 6.4 +2.8 6.3 +2.6 6.1 +3.0 7.7 +3.4 6.3 +3.1 6.4 +3.0 6.0 +3.1 6.9 +3.1 6.7 +3.1 6.9 +2.7 5.8 +3.2 6.8 +3.3 6.7 +3.0 6.7 +2.5 6.3 +3.0 6.5 +3.4 6.2 +3.0 5.9 +}\dataT + +\begin{tikzpicture} + +\definecolor{00cc96}{HTML}{00cc96} +\definecolor{636efa}{HTML}{636efa} +\definecolor{EF553B}{HTML}{EF553B} +\definecolor{darkslategrey}{RGB}{47, 79, 79} + +\begin{axis}[ +xlabel=sepal\_width, +ylabel=sepal\_length +] +\addplot+ [mark=diamond*, only marks, mark size=6, mark options={solid, fill=636efa, draw=darkslategrey, line width=1.5}] table[y=setosa] {\dataZ}; +\addlegendentry{setosa} +\addplot+ [mark=diamond*, only marks, mark size=6, mark options={solid, fill=EF553B, draw=darkslategrey, line width=1.5}] table[y=versicolor] {\dataO}; +\addlegendentry{versicolor} +\addplot+ [mark=diamond*, only marks, mark size=6, mark options={solid, fill=00cc96, draw=darkslategrey, line width=1.5}] table[y=virginica] {\dataT}; +\addlegendentry{virginica} +\end{axis} +\end{tikzpicture} diff --git a/tests/test_scatter.py b/tests/test_scatter.py index 5823d76..8107355 100644 --- a/tests/test_scatter.py +++ b/tests/test_scatter.py @@ -26,11 +26,127 @@ def plot_3(): fig = go.Figure(data=go.Scatter(x=x, y=x**2)) return fig +def plot_4(): + labels = ['Television', 'Newspaper', 'Internet', 'Radio'] + colors = ['rgb(67,67,67)', 'rgb(115,115,115)', 'rgb(49,130,189)', 'rgb(189,189,189)'] + + mode_size = [4, 4, 6, 4] + line_size = [2, 2, 4, 2] + + x_data = np.vstack((np.arange(2001, 2013),)*4) + + y_data = np.array([ + [74, 82, 80, 74, 73, 72, 74, 70, 70, 66, 66, 69], + [45, 42, 50, 46, 36, 36, 34, 35, 32, 31, 31, 28], + [13, 14, 20, 24, 20, 24, 24, 40, 35, 41, 43, 50], + [18, 21, 18, 21, 16, 14, 13, 18, 17, 16, 19, 23], + ]) + + fig = go.Figure() + + for i in range(0, 4): + fig.add_trace(go.Scatter(x=x_data[i], y=y_data[i], mode='lines', + name=labels[i], + line=dict(color=colors[i], width=line_size[i]), + connectgaps=True, + )) + + # endpoints + fig.add_trace(go.Scatter( + x=[x_data[i][0], x_data[i][-1]], + y=[y_data[i][0], y_data[i][-1]], + mode='markers', + marker=dict(color=colors[i], size=mode_size[i]) + )) + + fig.update_layout( + xaxis=dict( + showline=True, + showgrid=False, + showticklabels=True, + linecolor='rgb(204, 204, 204)', + linewidth=2, + ticks='outside', + tickfont=dict( + family='Arial', + size=12, + color='rgb(82, 82, 82)', + ), + ), + yaxis=dict( + showgrid=False, + zeroline=False, + showline=False, + showticklabels=False, + ), + autosize=False, + margin=dict( + autoexpand=False, + l=100, + r=20, + t=110, + ), + showlegend=False, + plot_bgcolor='white' + ) + + annotations = [] + + # Adding labels + for y_trace, label, color in zip(y_data, labels, colors): + # labeling the left_side of the plot + annotations.append(dict(xref='paper', x=0.05, y=y_trace[0], + xanchor='right', yanchor='middle', + text=label + ' {}%'.format(y_trace[0]), + font=dict(family='Arial', + size=16), + showarrow=False)) + # labeling the right_side of the plot + annotations.append(dict(xref='paper', x=0.95, y=y_trace[11], + xanchor='left', yanchor='middle', + text='{}%'.format(y_trace[11]), + font=dict(family='Arial', + size=16), + showarrow=False)) + # Title + annotations.append(dict(xref='paper', yref='paper', x=0.0, y=1.05, + xanchor='left', yanchor='bottom', + text='Main Source for News', + font=dict(family='Arial', + size=30, + color='rgb(37,37,37)'), + showarrow=False)) + # Source + annotations.append(dict(xref='paper', yref='paper', x=0.5, y=-0.1, + xanchor='center', yanchor='top', + text='Source: PewResearch Center & ' + + 'Storytelling with data', + font=dict(family='Arial', + size=12, + color='rgb(150,150,150)'), + showarrow=False)) + + fig.update_layout(annotations=annotations) + + # fig.show() + return fig + +def plot_5(): + df = px.data.stocks() + fig = px.line(df, x='date', y="GOOG") + return fig + def test_1(): - assert_equality(plot_1(), os.path.join(this_dir, test_name, test_name + "_1_reference.tikz")) + assert_equality(plot_1(), os.path.join(this_dir, test_name, test_name + "_1_reference.tex")) def test_2(): - assert_equality(plot_2(), os.path.join(this_dir, test_name, test_name + "_2_reference.tikz")) + assert_equality(plot_2(), os.path.join(this_dir, test_name, test_name + "_2_reference.tex")) def test_3(): - assert_equality(plot_3(), os.path.join(this_dir, test_name, test_name + "_3_reference.tikz")) \ No newline at end of file + assert_equality(plot_3(), os.path.join(this_dir, test_name, test_name + "_3_reference.tex")) + +def test_4(): + assert_equality(plot_4(), os.path.join(this_dir, test_name, test_name + "_4_reference.tex")) + +def test_5(): + assert_equality(plot_5(), os.path.join(this_dir, test_name, test_name + "_5_reference.tex")) \ No newline at end of file diff --git a/tests/test_scatter/test_scatter_1_reference.tikz b/tests/test_scatter/test_scatter_1_reference.tex similarity index 100% rename from tests/test_scatter/test_scatter_1_reference.tikz rename to tests/test_scatter/test_scatter_1_reference.tex diff --git a/tests/test_scatter/test_scatter_2_reference.tikz b/tests/test_scatter/test_scatter_2_reference.tex similarity index 100% rename from tests/test_scatter/test_scatter_2_reference.tikz rename to tests/test_scatter/test_scatter_2_reference.tex diff --git a/tests/test_scatter/test_scatter_3_reference.tikz b/tests/test_scatter/test_scatter_3_reference.tex similarity index 100% rename from tests/test_scatter/test_scatter_3_reference.tikz rename to tests/test_scatter/test_scatter_3_reference.tex diff --git a/tests/test_scatter/test_scatter_4_reference.tex b/tests/test_scatter/test_scatter_4_reference.tex new file mode 100644 index 0000000..74b0f6b --- /dev/null +++ b/tests/test_scatter/test_scatter_4_reference.tex @@ -0,0 +1,53 @@ +\pgfplotstableread{data0 Television Newspaper Internet Radio +2001 74 45 13 18 +2002 82 42 14 21 +2003 80 50 20 18 +2004 74 46 24 21 +2005 73 36 20 16 +2006 72 36 24 14 +2007 74 34 24 13 +2008 70 35 40 18 +2009 70 32 35 17 +2010 66 31 41 16 +2011 66 31 43 19 +2012 69 28 50 23 +}\dataZ +\pgfplotstableread{data1 y0 y1 y2 y3 +2001 74 45 13 18 +2012 69 28 50 23 +}\dataO + +\begin{tikzpicture} + +\definecolor{4bb96e9250}{RGB}{150,150,150} +\definecolor{6cb9a1c7d2}{RGB}{37,37,37} +\definecolor{6fb95895bc}{RGB}{67,67,67} +\definecolor{8b7c4ec1c1}{RGB}{49,130,189} +\definecolor{9b5dacb44d}{RGB}{115,115,115} +\definecolor{9f6fd82da0}{RGB}{189,189,189} + +\begin{axis}[ +axis background/.style={fill=white}, +axis y line=none, +clip=false +] +\addplot+ [mark=none, line width=1.5, color=6fb95895bc] table[y=Television] {\dataZ}; +\addplot+ [only marks, mark size=3, mark options={solid, fill=6fb95895bc}] table[y=y0] {\dataO}; +\addplot+ [mark=none, line width=1.5, color=9b5dacb44d] table[y=Newspaper] {\dataZ}; +\addplot+ [only marks, mark size=3, mark options={solid, fill=9b5dacb44d}] table[y=y1] {\dataO}; +\addplot+ [mark=none, line width=3, color=8b7c4ec1c1] table[y=Internet] {\dataZ}; +\addplot+ [only marks, mark size=4.5, mark options={solid, fill=8b7c4ec1c1}] table[y=y2] {\dataO}; +\addplot+ [mark=none, line width=1.5, color=9f6fd82da0] table[y=Radio] {\dataZ}; +\addplot+ [only marks, mark size=3, mark options={solid, fill=9f6fd82da0}] table[y=y3] {\dataO}; +\node[anchor= east] at (axis cs:\pgfkeysvalueof{/pgfplots/xmin} + 0.05*\pgfkeysvalueof{/pgfplots/xmax}-0.05*\pgfkeysvalueof{/pgfplots/xmin}, 74) {Television 74\%}; +\node[anchor= west] at (axis cs:\pgfkeysvalueof{/pgfplots/xmin} + 0.95*\pgfkeysvalueof{/pgfplots/xmax}-0.95*\pgfkeysvalueof{/pgfplots/xmin}, 69) {69\%}; +\node[anchor= east] at (axis cs:\pgfkeysvalueof{/pgfplots/xmin} + 0.05*\pgfkeysvalueof{/pgfplots/xmax}-0.05*\pgfkeysvalueof{/pgfplots/xmin}, 45) {Newspaper 45\%}; +\node[anchor= west] at (axis cs:\pgfkeysvalueof{/pgfplots/xmin} + 0.95*\pgfkeysvalueof{/pgfplots/xmax}-0.95*\pgfkeysvalueof{/pgfplots/xmin}, 28) {28\%}; +\node[anchor= east] at (axis cs:\pgfkeysvalueof{/pgfplots/xmin} + 0.05*\pgfkeysvalueof{/pgfplots/xmax}-0.05*\pgfkeysvalueof{/pgfplots/xmin}, 13) {Internet 13\%}; +\node[anchor= west] at (axis cs:\pgfkeysvalueof{/pgfplots/xmin} + 0.95*\pgfkeysvalueof{/pgfplots/xmax}-0.95*\pgfkeysvalueof{/pgfplots/xmin}, 50) {50\%}; +\node[anchor= east] at (axis cs:\pgfkeysvalueof{/pgfplots/xmin} + 0.05*\pgfkeysvalueof{/pgfplots/xmax}-0.05*\pgfkeysvalueof{/pgfplots/xmin}, 18) {Radio 18\%}; +\node[anchor= west] at (axis cs:\pgfkeysvalueof{/pgfplots/xmin} + 0.95*\pgfkeysvalueof{/pgfplots/xmax}-0.95*\pgfkeysvalueof{/pgfplots/xmin}, 23) {23\%}; +\node[anchor=south west, color=6cb9a1c7d2] at (rel axis cs:0.0, 1.05) {Main Source for News}; +\node[anchor=north, color=4bb96e9250] at (rel axis cs:0.5, -0.1) {Source: PewResearch Center \& Storytelling with data}; +\end{axis} +\end{tikzpicture} diff --git a/tests/test_scatter/test_scatter_5_reference.tex b/tests/test_scatter/test_scatter_5_reference.tex new file mode 100644 index 0000000..b90e837 --- /dev/null +++ b/tests/test_scatter/test_scatter_5_reference.tex @@ -0,0 +1,120 @@ +\pgfplotstableread{data0 y0 +2018-01-01 1.0 +2018-01-08 1.018172278347936 +2018-01-15 1.032007866452698 +2018-01-22 1.066782783389724 +2018-01-29 1.0087731636550117 +2018-02-05 0.9415276737437316 +2018-02-12 0.99325918262539 +2018-02-19 1.0222821547641083 +2018-02-26 0.9788520214265992 +2018-03-05 1.0524482730908842 +2018-03-12 1.0303929312465263 +2018-03-19 0.926821104067592 +2018-03-26 0.9360932452590338 +2018-04-02 0.913638710861412 +2018-04-09 0.93380695379017 +2018-04-16 0.9734447261178653 +2018-04-23 0.9345146364100892 +2018-04-30 0.9509902470625956 +2018-05-07 0.9963982380519172 +2018-05-14 0.9674568868105002 +2018-05-21 0.9758943718805396 +2018-05-28 1.015668254641377 +2018-06-04 1.0169111849053498 +2018-06-11 1.0453898287179595 +2018-06-18 1.0483111519067918 +2018-06-25 1.0121753574512644 +2018-07-02 1.0344211867653972 +2018-07-09 1.0785588920381208 +2018-07-16 1.075011617811375 +2018-07-23 1.1236312044424703 +2018-07-30 1.1102129167272332 +2018-08-06 1.1228237368393843 +2018-08-13 1.0895729410299655 +2018-08-20 1.1074367837463466 +2018-08-27 1.1052048693141154 +2018-09-03 1.0567939333314087 +2018-09-10 1.0637798374890872 +2018-09-17 1.0579370795194665 +2018-09-24 1.0827776350267664 +2018-10-01 1.0500077089175164 +2018-10-08 1.007121903906116 +2018-10-15 0.9947651405743836 +2018-10-22 0.9720929301886708 +2018-10-29 0.959681788913054 +2018-11-05 0.9672663993407256 +2018-11-12 0.9630385756700248 +2018-11-19 0.9289168536315806 +2018-11-26 0.992923504040418 +2018-12-03 0.9404389054995582 +2018-12-10 0.945446952912676 +2018-12-17 0.8886892896888904 +2018-12-24 0.9408925313390586 +2018-12-31 0.9714034098401132 +2019-01-07 0.9591373489949891 +2019-01-14 0.9963982380519172 +2019-01-21 0.989802500200548 +2019-01-28 1.0077298024501202 +2019-02-04 0.9934950771344468 +2019-02-11 1.0103608540932627 +2019-02-18 1.0073850422758417 +2019-02-25 1.035165084150587 +2019-03-04 1.0363716889645844 +2019-03-11 1.0746032883264525 +2019-03-18 1.0936918990354445 +2019-03-25 1.064487521016258 +2019-04-01 1.095188886079836 +2019-04-08 1.1049145977684258 +2019-04-15 1.1216987538299403 +2019-04-22 1.1541874899828073 +2019-04-29 1.075456162061569 +2019-05-06 1.0562859304552756 +2019-05-13 1.0544986709579427 +2019-05-20 1.0283425342867192 +2019-05-27 1.001270175031893 +2019-06-03 0.9671666152648106 +2019-06-10 0.98468558802946 +2019-06-17 1.0178275181736574 +2019-06-24 0.980657443195294 +2019-07-01 1.0266368965939394 +2019-07-08 1.0387124690620373 +2019-07-15 1.025285100664745 +2019-07-22 1.1344366027859267 +2019-07-29 1.0832494231376286 +2019-08-05 1.0778240762422375 +2019-08-12 1.068379555417282 +2019-08-19 1.0445098208996275 +2019-08-26 1.0779056980467905 +2019-09-02 1.0931748145700046 +2019-09-09 1.12459294475006 +2019-09-16 1.115856106545024 +2019-09-23 1.1114649285805127 +2019-09-30 1.0968672799119472 +2019-10-07 1.10271900878617 +2019-10-14 1.129972884606169 +2019-10-21 1.1477913211905195 +2019-10-28 1.155602744537941 +2019-11-04 1.189742629754999 +2019-11-11 1.2110630442115171 +2019-11-18 1.1751993590303178 +2019-11-25 1.183927115646047 +2019-12-02 1.216279741365772 +2019-12-09 1.222820990588552 +2019-12-16 1.22441776261611 +2019-12-23 1.2265044859331442 +2019-12-30 1.213013658002661 +}\dataZ + +\begin{tikzpicture} + +\definecolor{636efa}{HTML}{636efa} + +\begin{axis}[ +date coordinates in=x, +xlabel=date, +ylabel=GOOG +] +\addplot+ [mark=none, solid, color=636efa, forget plot] table[y=y0] {\dataZ}; +\end{axis} +\end{tikzpicture} diff --git a/tox.ini b/tox.ini index d8109fb..cb3d533 100644 --- a/tox.ini +++ b/tox.ini @@ -11,5 +11,6 @@ deps = pytest-codeblocks plotly pytest-randomly + kaleido commands = pytest {posargs} \ No newline at end of file From eed173b107fd5c988ec173173fda1f8a2c49561f Mon Sep 17 00:00:00 2001 From: Thomas Saigre Date: Tue, 14 May 2024 17:06:31 +0200 Subject: [PATCH 3/9] up continuous integration : to be targeted on push to main or in pull requests --- .github/workflows/ci.yml | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..eb5200e --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,40 @@ +name: ci + +on: + push: + branches: + - main + pull_request: + branches: + - '*' # all branches + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - name: Check out repo + uses: actions/checkout@v2 + - name: Set up Python + uses: actions/setup-python@v2 + - name: Run pre-commit + uses: pre-commit/action@v2.0.3 + + build: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, windows-latest, macOS-latest] + python-version: ["3.7", "3.8", "3.9", "3.10"] + steps: + - uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - uses: actions/checkout@v2 + # - name: Install system dependencies + # run: sudo apt-get install -y texlive-latex-base texlive-latex-extra context python3-tk + - name: Test with tox + run: | + pip install tox + tox -- --cov tikzplotly --cov-report xml --cov-report term + - uses: codecov/codecov-action@v1 + if: ${{ matrix.python-version == '3.10' && matrix.os == 'ubuntu-latest' }} From c9feb9fb1662ba74b8aba07b7ab8fbff52260ed9 Mon Sep 17 00:00:00 2001 From: Thomas Saigre Date: Wed, 15 May 2024 10:23:37 +0200 Subject: [PATCH 4/9] attemp to fix ci #12 --- .github/workflows/ci.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index eb5200e..7db6c40 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,11 +13,11 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out repo - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Set up Python - uses: actions/setup-python@v2 - - name: Run pre-commit - uses: pre-commit/action@v2.0.3 + uses: actions/setup-python@v3 + with: + python-version: '3.x' build: runs-on: ${{ matrix.os }} @@ -26,10 +26,10 @@ jobs: os: [ubuntu-latest, windows-latest, macOS-latest] python-version: ["3.7", "3.8", "3.9", "3.10"] steps: - - uses: actions/setup-python@v2 + - uses: actions/setup-python@v3 with: python-version: ${{ matrix.python-version }} - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 # - name: Install system dependencies # run: sudo apt-get install -y texlive-latex-base texlive-latex-extra context python3-tk - name: Test with tox From fc5bb18de2e6fca595dcb06443c2b769c5a205e0 Mon Sep 17 00:00:00 2001 From: Thomas Saigre Date: Wed, 15 May 2024 10:58:10 +0200 Subject: [PATCH 5/9] disable python 3.7 #12 --- .github/workflows/ci.yml | 3 ++- pyproject.toml | 1 - 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7db6c40..8eb327d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,9 +22,10 @@ jobs: build: runs-on: ${{ matrix.os }} strategy: + fail-fast: false matrix: os: [ubuntu-latest, windows-latest, macOS-latest] - python-version: ["3.7", "3.8", "3.9", "3.10"] + python-version: ["3.8", "3.9", "3.10"] steps: - uses: actions/setup-python@v3 with: diff --git a/pyproject.toml b/pyproject.toml index 3d74da7..b41e393 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -13,7 +13,6 @@ classifiers = [ "Development Status :: 5 - Production/Stable", "Programming Language :: Python", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", From e3579d0f7d917b09df509ca4893d3a3a4bafe043 Mon Sep 17 00:00:00 2001 From: Thomas Saigre Date: Wed, 15 May 2024 11:23:32 +0200 Subject: [PATCH 6/9] disable windows in tests #12 --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8eb327d..b073019 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,7 +24,7 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-latest, windows-latest, macOS-latest] + os: [ubuntu-latest, macOS-latest] python-version: ["3.8", "3.9", "3.10"] steps: - uses: actions/setup-python@v3 From 22d696f029ea450e1b40803a7cc3a842af58097e Mon Sep 17 00:00:00 2001 From: Thomas Saigre Date: Wed, 15 May 2024 11:27:50 +0200 Subject: [PATCH 7/9] fix signature of the function to be compatible with previous version of python #14 --- src/tikzplotly/_save.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tikzplotly/_save.py b/src/tikzplotly/_save.py index 13e6eef..7163d8e 100755 --- a/src/tikzplotly/_save.py +++ b/src/tikzplotly/_save.py @@ -110,7 +110,7 @@ def get_tikz_code( return code -def save(filepath: str | Path, *args, encoding: str | None = None, **kwargs): +def save(filepath, *args, **kwargs): """Save a figure to a file or a stream. Parameters From 9ece4bab5345e3a875df6d634bdbd5086b1276b7 Mon Sep 17 00:00:00 2001 From: Thomas Saigre Date: Wed, 15 May 2024 12:39:00 +0200 Subject: [PATCH 8/9] Update codecov-action to v4.0.1 #12 --- .github/workflows/ci.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b073019..26f9dbf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -37,5 +37,7 @@ jobs: run: | pip install tox tox -- --cov tikzplotly --cov-report xml --cov-report term - - uses: codecov/codecov-action@v1 + - uses: codecov/codecov-action@v4.0.1 if: ${{ matrix.python-version == '3.10' && matrix.os == 'ubuntu-latest' }} + with: + token: ${{ secrets.CODECOV_TOKEN }} From 5c2e5ada3ec46ac26d864c668b88faa253daa618 Mon Sep 17 00:00:00 2001 From: Thomas Saigre Date: Wed, 15 May 2024 13:30:40 +0200 Subject: [PATCH 9/9] chore: Update pyproject.toml and version number to 0.1.6 [ci skip] --- README.md | 3 +++ pyproject.toml | 2 +- src/tikzplotly/__about__.py | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 635e1c6..faef1a9 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,9 @@ [![PyPI pyversions](https://img.shields.io/pypi/pyversions/tikzplotly.svg?style=flat-square)](https://pypi.org/pypi/tikzplotly/) [![Issue](https://img.shields.io/github/issues-raw/thomas-saigre/tikzplotly?style=flat-square)](https://github.com/thomas-saigre/tikzplotly/issues) +[![codecov](https://img.shields.io/codecov/c/github/thomas-saigre/tikzplotly.svg?style=flat-square)](https://codecov.io/gh/thomas-saigre/tikzplotly) +![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/thomas-saigre/tikzplotly/ci.yml?style=flat-square) + # Tikzplotly diff --git a/pyproject.toml b/pyproject.toml index b41e393..74f11cc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "tikzplotly" -version = "0.1.5" +version = "0.1.6" description = "Convert plotly figures to LaTeX / tikz figures" readme = "README.md" authors = [{name = "Thomas Saigre", email = "tikzplotly@outlook.fr"}] diff --git a/src/tikzplotly/__about__.py b/src/tikzplotly/__about__.py index 51e0a06..32efefd 100755 --- a/src/tikzplotly/__about__.py +++ b/src/tikzplotly/__about__.py @@ -1 +1 @@ -__version__ = "0.1.4" \ No newline at end of file +__version__ = "0.1.6" \ No newline at end of file