plotly / plotly.js

Open-source JavaScript charting library behind Plotly and Dash
https://plotly.com/javascript/
MIT License
16.81k stars 1.85k forks source link

enable changing the color of marker icons in a ScatterMapBox plot #6599

Open serboba opened 1 year ago

serboba commented 1 year ago
<head>
    <!-- Load plotly.js into the DOM -->
    <script src='https://cdn.plot.ly/plotly-2.20.0.min.js'></script>
</head>

<body>
    <div id='myDiv'><!-- Plotly chart will be drawn inside this DIV --></div>
        <script>
        var data = [
    {
        type: "scattermapbox",
        mode: "markers+text+lines",
        lon: [-75, -80, -50],
        lat: [45, 20, -20],
                color:'red',
        marker: { size: 20, symbol: 'bus' },
        text: 'bus',
        textposition: "bottom right"
    }
];

var layout = {
    mapbox: { style: "outdoors", zoom: 0.7 },
    showlegend: false, height: 500, width: 700
};

var config = {mapboxAccessToken: mytoken};

Plotly.newPlot("myDiv", data, layout, config);

    </script>
</body>

I tried to change the color of the MAKI icons by trying to specify it inside marker dict but it does not work. However, changing the style of mapbox in the layout changes the color of the icons. So it should be possible to specify the color in the marker too (without changing the style). I could not find any information about this in the documentation.

Many thanks in advance.

Kully commented 1 year ago

I could not find any information about this in the documentation.

See here:

https://plotly.com/python/reference/scattermapbox/#scattermapbox-marker-symbol

image
serboba commented 1 year ago

Yes, but this works only if the marker symbol is not a MAKI icon.