hardcode boxplot offset

227 views
Skip to first unread message

Donia Bzz

unread,
Sep 25, 2019, 4:26:21 PM9/25/19
to desmos-api-discuss
Hi,
How can I parameter boxplot offset and height using the api? I've tried some coding : calculator.setExpression({id:'boxS', latex: '\\operatorname{boxplot}\\left(S\\right)', vizProps: {axisOffset: 3, breadth: 1},  color: colourSi}); but it doesn't work. Is there a way to do so? The goal is to display multiple boxplots in one sheet.
Thanks,

Donia

Jason Merrill

unread,
Sep 25, 2019, 5:03:03 PM9/25/19
to desmos-api-discuss
Hi Donia,

It is not currently possible to set vizProps through the API, but adding this in a future version sounds like a good idea.

In the meantime, depending on exactly what you're doing, I would recommend building a graph in the graphing calculator that sets up offsets the way you want, saving it using calc.getState(), loading it into the API using calc.setState(), and then only adjusting the dynamic parts of the graph in the API using calc.setExpression(). We've generally found that doing as much authoring as you can in the calculator is an easier workflow than authoring complicated graphs entirely with API calls.

--Jason

Sina Azizi

unread,
Nov 30, 2020, 12:23:21 PM11/30/20
to desmos-api-discuss
Hi Jason, 
What you said is exactly what I've been missing. To build graphs in calculator and then importing them using setState. 

How can I get state do this in a graph I created within Desmos.com? Do I need specific server configuration?

Chris Lusto

unread,
Nov 30, 2020, 5:49:24 PM11/30/20
to desmos-api-discuss
There are two ways to get a saved graph state from desmos.com to load into your own calculator instance using `setState()`.

1. Open the graph on desmos.com and copy the result of `Calc.getState()` from the console.
2. Hit the saved graph's URL but specifically request a JSON response. If you ask us for JSON (say, using jQuery's `.getJSON()` method), we'll send you the serialized graph state as part of the response body. You can see this in action easily from the command line: `curl -H 'accept: application/json' https://www.desmos.com/calculator/2rnqgoa6a4` will return JSON instead of HTML. The returned JSON has a `.state` property that is suitable to pass into `.setState()`.

Note, however, that it's possible to build graphs on desmos.com that won't display as expected in the current stable API version, because the www calculator always runs the edge/experimental version of the API. For example, since the release of API v1.5 we have added new syntax and functions for working with lists. Any graph you build on desmos.com that makes use of those features will be broken when displayed in a v1.5 calculator instance, because those functions and syntax didn't yet exist when v1.5 was stabilized. (In other words, though we work very hard to be backwards compatible, we can't promise forwards compatibility, because we can't predict future features.) The absolute safest thing to do would be to author graphs in the same (or earlier) API version that you intend to load the graph in for consumption. What some content partners end up doing is building a lightweight authoring page that saves graph states to their own storage location rather than keeping them on desmos.com, because that way they can enforce API versioning.

Hope that helps!

Best,
Chris @ Desmos 

Sina Azizi

unread,
Nov 30, 2020, 5:56:27 PM11/30/20
to Chris Lusto, desmos-api-discuss
Thanks Chris, first helping with the API key, now with this... man you're awesome. 

I also noticed in the calculator there are more styling options as well (line thickness). 

Thanks for the response 
Best Regards,

Sina - Founder 
UC3D.io

--
You received this message because you are subscribed to the Google Groups "desmos-api-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to desmos-api-disc...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/desmos-api-discuss/12cc49df-3b0e-443d-aa3e-0c30a815547dn%40googlegroups.com.

Reply all
Reply to author
Forward
0 new messages