diff --git a/dingo/illustrations.py b/dingo/illustrations.py index 60aaa8af..00f2cba2 100644 --- a/dingo/illustrations.py +++ b/dingo/illustrations.py @@ -8,9 +8,10 @@ import numpy as np import matplotlib.pyplot as plt import plotly.graph_objects as go +import plotly.io as pio from dingo.utils import compute_copula -def plot_copula(data_flux1, data_flux2, n = 5): +def plot_copula(data_flux1, data_flux2, n = 5, width = 900 , height = 600, export_format = "svg"): """A Python function to plot the copula between two fluxes Keyword arguments: @@ -25,15 +26,38 @@ def plot_copula(data_flux1, data_flux2, n = 5): flux2 = data_flux2[0] copula = compute_copula(flux1, flux2, n) - fig = go.Figure(data=[go.Surface(z=copula)]) + fig = go.Figure( + data = [go.Surface(z=copula)], + layout = go.Layout( + height = height, + width = width, + ) + ) - fig.update_layout(title='Copula between '+data_flux1[1]+' and '+data_flux2[1], autosize=False, - width=500, height=500, scene = dict(xaxis_title=data_flux1[1], - yaxis_title=data_flux2[1], zaxis_title='prob. mass'), - margin=dict(l=65, r=50, b=65, t=90)) + + fig.update_layout( + title = 'Copula between '+ data_flux1[1] + ' and ' + data_flux2[1], + scene = dict( + xaxis_title= data_flux1[1], + yaxis_title= data_flux2[1], + zaxis_title="prob, mass" + ), + margin=dict(r=30, b=30, l=30, t=50)) + + fig.layout.template = None - fig.update_layout() fig.show() + fig_name = data_flux1[1] + "_" + data_flux2[1] + "_copula." + export_format + + camera = dict( + up=dict(x=0, y=0, z=1), + center=dict(x=0, y=0, z=0), + eye=dict(x=1.25, y=1.25, z=1.25) + ) + + fig.update_layout(scene_camera=camera) + fig.to_image(format = export_format, engine="kaleido") + pio.write_image(fig, fig_name, scale=2) def plot_histogram(reaction_fluxes, reaction, n_bins=40): diff --git a/doc/aconta_ppc_copula.png b/doc/aconta_ppc_copula.png index 845446b2..e054f6c1 100644 Binary files a/doc/aconta_ppc_copula.png and b/doc/aconta_ppc_copula.png differ diff --git a/poetry.lock b/poetry.lock index ed525e3b..598593c5 100644 --- a/poetry.lock +++ b/poetry.lock @@ -485,6 +485,22 @@ zipp = {version = ">=3.1.0", markers = "python_version < \"3.10\""} docs = ["furo", "jaraco.packaging (>=9)", "jaraco.tidelift (>=1.4)", "rst.linker (>=1.9)", "sphinx (>=3.5)"] testing = ["flake8 (<5)", "pytest (>=6)", "pytest-black (>=0.3.7)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=1.3)", "pytest-flake8", "pytest-mypy (>=0.9.1)"] +[[package]] +name = "kaleido" +version = "0.2.1" +description = "Static image export for web-based visualization libraries with zero dependencies" +category = "main" +optional = false +python-versions = "*" +files = [ + {file = "kaleido-0.2.1-py2.py3-none-macosx_10_11_x86_64.whl", hash = "sha256:ca6f73e7ff00aaebf2843f73f1d3bacde1930ef5041093fe76b83a15785049a7"}, + {file = "kaleido-0.2.1-py2.py3-none-macosx_11_0_arm64.whl", hash = "sha256:bb9a5d1f710357d5d432ee240ef6658a6d124c3e610935817b4b42da9c787c05"}, + {file = "kaleido-0.2.1-py2.py3-none-manylinux1_x86_64.whl", hash = "sha256:aa21cf1bf1c78f8fa50a9f7d45e1003c387bd3d6fe0a767cfbbf344b95bdc3a8"}, + {file = "kaleido-0.2.1-py2.py3-none-manylinux2014_aarch64.whl", hash = "sha256:845819844c8082c9469d9c17e42621fbf85c2b237ef8a86ec8a8527f98b6512a"}, + {file = "kaleido-0.2.1-py2.py3-none-win32.whl", hash = "sha256:ecc72635860be616c6b7161807a65c0dbd9b90c6437ac96965831e2e24066552"}, + {file = "kaleido-0.2.1-py2.py3-none-win_amd64.whl", hash = "sha256:4670985f28913c2d063c5734d125ecc28e40810141bdb0a46f15b76c1d45f23c"}, +] + [[package]] name = "kiwisolver" version = "1.4.4" @@ -1409,4 +1425,4 @@ testing = ["flake8 (<5)", "func-timeout", "jaraco.functools", "jaraco.itertools" [metadata] lock-version = "2.0" python-versions = "^3.8" -content-hash = "3d3a18400deca5b870f1e6b38e82afe55a1fe2d40aef82979d6e77ed4196d9a2" +content-hash = "6c3c9de7f7300952d2553972b8595129b073e6210aeda83cdcbb256b743e2867" diff --git a/pyproject.toml b/pyproject.toml index f76acd95..35b38b59 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -16,6 +16,8 @@ argparse = "^1.4.0" matplotlib = "^3.4.1" cobra = "^0.26.0" plotly = "^5.11.0" +#kaleido = "0.2.1" +kaleido = "0.2.1" [tool.poetry.dev-dependencies]