Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DOCS] documentation on how to include matlibplots in the community version #2254

Open
1 of 7 tasks
mjpan opened this issue Nov 17, 2024 · 2 comments
Open
1 of 7 tasks
Assignees
Labels
💬 Discussion Requires some discussion and decision 📄 Documentation Internal or public documentation

Comments

@mjpan
Copy link

mjpan commented Nov 17, 2024

Issue Description

On this page, it seems to indicate that matlibplots are available in all versions (including community version)
https://taipy.io/pricing

however, when I try to replace a Plotly chart (stubbed in a Markdown page, and created in Python), with a matlibplot, I get the following error.
TaipyGuiWarning: 'figure' property value must be a plotly.graph_objects.Figure.
_warn("'figure' property value must be a plotly.graph_objects.Figure.")

The only documentation that I can find about matlibplot is in Taipy Designer, which seems to indicate that both Plotly and matlibplot both use "fig" in the Designer, which does not seem to be part of the community version.

Code of Conduct

  • I have checked the existing issues.
  • I am willing to work on this issue (optional)

Acceptance Criteria

  • The documentation set as been generated without error.
  • The new text has been passed to a grammatical tool for review.
  • The 100 character length limit has been respected as much as possible.
  • The links and cross-references in the documentation are working.
  • If applicable, screenshots of the new documentation are added to the pull request.
@mjpan mjpan added the 📄 Documentation Internal or public documentation label Nov 17, 2024
@FlorianJacta
Copy link
Member

Check this documentation on how to integrate MatPlotlib.

from matplotlib.figure import Figure
import numpy as np
from taipy import Gui 

def koch_snowflake(order, scale=10):
    def _complex(order):
        if order == 0:
            # initial triangle
            angles = np.array([0, 120, 240]) + 90
            return scale / np.sqrt(3) * np.exp(np.deg2rad(angles) * 1j)
        else:
            ZR = 0.5 - 0.5j * np.sqrt(3) / 3

            p1 = _complex(order - 1)  # start points
            p2 = np.roll(p1, shift=-1)  # end points
            dp = p2 - p1  # connection vectors

            new_points = np.empty(len(p1) * 4, dtype=np.complex128)
            new_points[::4] = p1
            new_points[1::4] = p1 + dp / 3
            new_points[2::4] = p1 + dp * ZR
            new_points[3::4] = p1 + dp / 3 * 2
            return new_points

    points = _complex(order)
    x, y = points.real, points.imag
    return x, y

figure = Figure(figsize=(5, 5))
plot = figure.subplots(1, 1)
x, y = koch_snowflake(4)
plot.fill(x, y, facecolor='none', edgecolor='purple', linewidth=2)

import taipy.gui.builder as tgb
with tgb.Page() as page:
    tgb.part(content="{figure}", height="520px")

Gui(page).run()

@FlorianJacta
Copy link
Member

Can I close the issue? @mjpan

@FlorianJacta FlorianJacta self-assigned this Nov 18, 2024
@FlorianJacta FlorianJacta added the 💬 Discussion Requires some discussion and decision label Nov 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💬 Discussion Requires some discussion and decision 📄 Documentation Internal or public documentation
Projects
None yet
Development

No branches or pull requests

2 participants