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

clog-plotly #324

Closed
pierceglenn12345 opened this issue Feb 12, 2024 · 2 comments
Closed

clog-plotly #324

pierceglenn12345 opened this issue Feb 12, 2024 · 2 comments

Comments

@pierceglenn12345
Copy link

pierceglenn12345 commented Feb 12, 2024

I am not great at understanding where/how to properly ask of this, but...

How are you getting your json code together for passing through to (clog-plotly:new-plot-plotly ...?). I have tried writing python to build a graph, then outputting json and adding to the function above like (using run-python in emacs):

import plotly.express as px
import plotly as pl
fig = px.bar(x=["a", "b", "c"], y=[1, 3, 2])
fig.show

=>
'data': [{'alignmentgroup': 'True',
'hovertemplate': 'x=%{x}
y=%{y}',
'legendgroup': '',
'marker': {'color': '#636efa', 'pattern': {'shape': ''}},
'name': '',
'offsetgroup': '',
'orientation': 'v',
'showlegend': False,
'textposition': 'auto',
'type': 'bar',
'x': array(['a', 'b', 'c'], dtype=object),
'xaxis': 'x',
'y': array([1, 3, 2]),
'yaxis': 'y'}],
'layout': {'barmode': 'relative',
'legend': {'tracegroupgap': 0},
'margin': {'t': 60},
'template': '...',
'xaxis': {'anchor': 'y', 'domain': [0.0, 1.0], 'title': {'text': 'x'}},
'yaxis': {'anchor': 'x', 'domain': [0.0, 1.0], 'title': {'text': 'y'}}}
})>

I push this into CL as:
(clog-plotly:new-plot-plotly target
"[{'alignmentgroup': 'True',
'hovertemplate': 'x=%{x}
y=%{y}',
'legendgroup': '',
'marker': {'color': '#636efa', 'pattern': {'shape': ''}},
'name': '',
'offsetgroup': '',
'orientation': 'v',
'showlegend': False,
'textposition': 'auto',
'type': 'bar',
'x': array(['a', 'b', 'c'], dtype=object),
'xaxis': 'x',
'y': array([1, 3, 2]),
'yaxis': 'y'}]"
"{'barmode': 'relative',
'legend': {'tracegroupgap': 0},
'margin': {'t': 60},
'template': '...',
'xaxis': {'anchor': 'y', 'domain': [0.0, 1.0], 'title': {'text': 'x'}},
'yaxis': {'anchor': 'x', 'domain': [0.0, 1.0], 'title': {'text': 'y'}}}")

This results in an empty clog-plotly "panel"?, so it isn't working. Is there a better way to go about this? I realize I am not up to speed on how plotly works, so my question is more along the lines of how one would go from having common lisp list data, to a plotly chart. Again, this is more of a workflow question about staying in common lisp land more than having to jump into python to get json made. Maybe I need to create a library for taking lisp data and, through something like cl-jonathan output json I can then push right into the two parameters for (clog-plotly:new-plot-plotly ...?). Maybe even integrate lisp-stat and dataframes? Looking for thoughts/idea's. Love the project btw.

PS - Is there an IRC channel for the project? Discord? etc?

@rabbibotton
Copy link
Owner

Mainly we discuss clog here in the discussion area.

https://plotly.com/javascript/ for details on what goes in to the json.

As for the json, I just paste it in

(clog-plotly::new-plot-plotly target
"[
        {
            type: 'scatter',
            x: [1, 2, 3],
            y: [3, 1, 6],
            marker: { 
                color: 'rgb(16, 32, 77)'
            }
        },
        {
            type: 'bar',
            x: [1, 2, 3],
            y: [3, 1, 6],
            name: 'bar chart example'
        }
    ]"
"{
        title: 'simple example',
        xaxis: {
            title: 'time'
        },
        annotations: [
            {
                text: 'simple annotation',
                x: 0,
                xref: 'paper',
                y: 0,
                yref: 'paper'
            }
        ]
    }")

Of course you could generate the json using various CL json packages

@pierceglenn12345
Copy link
Author

Okay. Thanks for the input. I will move over to discussions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants