pi labels on axes

44 views
Skip to first unread message

Andy

unread,
Oct 19, 2023, 12:50:51 PM10/19/23
to desmos-api-discuss
According to this helpful web page https://help.desmos.com/hc/en-us/articles/4405296853517-Graph-Settings it is possible to put pi tick marks on the axis of a graph.

Can this be done using the API? I would like my graph to show up with the x axis marked off by pi's.

I tried 

var calculator = Desmos.GraphingCalculator(elt,{zoomFit:true,showResetButtonOnGraphpaper:true,xAxisStep:"pi"});

I tried
var calculator = Desmos.GraphingCalculator(elt,{showResetButtonOnGraphpaper:true,xAxisStep:3.14159265});

I tried

calculator.updateSettings({xAxisStep:'pi'});

Bruce B. Birkett

unread,
Oct 24, 2023, 2:55:52 PM10/24/23
to desmos-api-discuss
This would do it:

```
var calculator1 = Desmos.GraphingCalculator(elt, {settingsMenu:false, zoomButtons: false, lockViewport: true, expressions: false});
calculator1.setState(
{
    "version": 10,
    "randomSeed": "72ee2480bc9004d80d35fc0a846da51b",
    "graph": {
        "viewport": {
            "xmin": -10,
            "ymin": -5.526735833998404,
            "xmax": 10,
            "ymax": 5.526735833998404
        },
        "xAxisStep": 3.141592653589793
    },
    "expressions": {
        "list": [
            {
                "type": "expression",
                "id": "1",
                "color": "#c74440",
                "latex": "f\\left(x\\right)\\ =\\ \\sin\\left(x\\right)"
            }
        ]
    }
}
)
```
In general I find it easiest to use Desmos' web interface to set up the graph initially, including entering equations, setting the viewport, axis steps, etc.  Then in the browser's console type copy(Calc.getState()); which will copy the calculator's state to your clipboard.  (You'll probably get `undefined` back; ignore that.) Finally paste the clipboard contents into your code:
```
var calculator1 = Desmos.GraphingCalculator(elt1, {settingsMenu:false, zoomButtons: false, lockViewport: true, expressions: false});
calculator1.setState(
[PASTE HERE]
)
```
You can then modify as needed from there.

Hope that helps!

Andy

unread,
Oct 27, 2023, 10:36:39 AM10/27/23
to desmos-api-discuss
Thanks. This is very helpful!
Reply all
Reply to author
Forward
0 new messages