plotly / plotly/plotly.js

Wrong layout when adjusting gap between positive-side violin plots.

Ouverte
#7,350 1 commentaire 0 réactions 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

bug P3
Langage dominant
JavaScript
Étoiles
18.3k
Forks
2k
Merge moyen
2 j 12 h
PR mergées (30 j)
28

Description

When showing two violin plots in the same graph, it is possible to control the size of the gap between them. If changing the plots to show only the positive side, this breaks (the top graph is placed in the wrong location and is clipped).

This works:

<html>
<head>
<meta charset="utf-8" />
</head>
<body>
<div id=id-1 class="plotly-graph-div" style="height:100%; width:100%;"></div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_SVG"></script>
<script src="https://cdn.plot.ly/plotly-2.3.0.min.js"></script>
<script type="text/javascript">
window.PlotlyConfig = {MathJaxConfig: 'local'};
window.PLOTLYENV = window.PLOTLYENV || {}
if (document.getElementById('id-1')) {
    Plotly.newPlot(
        'id-1',
        [{
                "boxpoints": false,
                "type": "violin",
                "name": "Trace 1",
                "points": false,
                "box": {
                    "visible": false
                },
                "legendgroup": "Trace 1",
                "x": [0.75, 5.25, 5.5, 6.0, 6.2, 6.6, 6.8, 7.0, 7.2, 7.5, 7.5, 7.75, 8.15, 8.15, 8.65, 8.93, 9.2, 9.5, 10.0, 10.25, 11.5, 12.0, 16.0, 20.9, 22.3, 23.25]
            },
            {
                "boxpoints": false,
                "type": "violin",
                "name": "Trace 2",
                "points": false,
                "box": {
                    "visible": false
                },
                "legendgroup": "Trace 2",
                "x": [7.9, 5.4, 7.4, 6.2, 8.5, 5.5, 8.8, 8.5, 5.1, 8.5, 5.4, 8.4, 7.8, 4.7, 8.3, 5.2, 6.2, 8.4, 5.2, 7.9, 5.1, 4.7, 7.8, 6.9, 7.4, 8.3, 5.5, 7.6, 7.8, 7.9, 7.3, 7.7, 6.6, 8.0, 7.4, 5.2, 4.8, 8.0, 5.9, 9.0, 8.0, 5.8, 8.4, 5.8, 7.3, 8.3, 6.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.3, 7.3, 7.3, 8.8, 8.0, 7.1, 8.3, 5.6, 7.9, 7.8, 8.4, 5.8, 8.3, 4.3, 6.0, 7.5, 8.1, 4.6, 9.0, 4.6, 7.4, 14.0, 15.0]
            }
        ], {
            "showlegend": false,
            "xaxis": {
                "showgrid": true,
                "gridcolor": "lightgrey",
                "showticklabels": true,
                "range": [0.75, 23.25]
            },
            "boxgroupgap": 0,
            "violingap": 0.1,
            "template": "simple_white",
            "boxgap": 0.1,
            "legend": {
                "tracegroupgap": 0,
                "itemdoubleclick": false
            },
            "yaxis": {
                "showgrid": false,
                "gridcolor": "lightgrey",
                "showticklabels": false,
                "range": [null, null]
            },
            "violingroupgap": 0,
            "margin": {
                "l": 50,
                "b": 50,
                "r": 50,
                "t": 50
            }
        }, {
            "editable": false,
            "responsive": true,
            "staticPlot": false,
            "scrollZoom": true
        },
    )
}
</script>
</body>
</html>

It shows:

Image

This fails (the only difference is adding "side":"positive", to the traces):

<html>
<head>
<meta charset="utf-8" />
</head>
<body>
<div id=id-1 class="plotly-graph-div" style="height:100%; width:100%;"></div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_SVG"></script>
<script src="https://cdn.plot.ly/plotly-2.3.0.min.js"></script>
<script type="text/javascript">
window.PlotlyConfig = {MathJaxConfig: 'local'};
window.PLOTLYENV = window.PLOTLYENV || {}
if (document.getElementById('id-1')) {
    Plotly.newPlot(
        'id-1',
        [{
                "side":"positive",
                "boxpoints": false,
                "type": "violin",
                "name": "Trace 1",
                "points": false,
                "box": {
                    "visible": false
                },
                "legendgroup": "Trace 1",
                "x": [0.75, 5.25, 5.5, 6.0, 6.2, 6.6, 6.8, 7.0, 7.2, 7.5, 7.5, 7.75, 8.15, 8.15, 8.65, 8.93, 9.2, 9.5, 10.0, 10.25, 11.5, 12.0, 16.0, 20.9, 22.3, 23.25]
            },
            {
                "side":"positive",
                "boxpoints": false,
                "type": "violin",
                "name": "Trace 2",
                "points": false,
                "box": {
                    "visible": false
                },
                "legendgroup": "Trace 2",
                "x": [7.9, 5.4, 7.4, 6.2, 8.5, 5.5, 8.8, 8.5, 5.1, 8.5, 5.4, 8.4, 7.8, 4.7, 8.3, 5.2, 6.2, 8.4, 5.2, 7.9, 5.1, 4.7, 7.8, 6.9, 7.4, 8.3, 5.5, 7.6, 7.8, 7.9, 7.3, 7.7, 6.6, 8.0, 7.4, 5.2, 4.8, 8.0, 5.9, 9.0, 8.0, 5.8, 8.4, 5.8, 7.3, 8.3, 6.4, 5.3, 8.2, 5.9, 7.5, 9.0, 5.4, 8.0, 5.4, 8.3, 7.1, 6.4, 7.7, 8.1, 5.9, 8.4, 4.8, 8.2, 6.0, 9.2, 7.8, 7.8, 6.5, 7.3, 8.2, 5.6, 7.9, 7.1, 6.2, 7.6, 6.0, 7.8, 7.6, 8.3, 7.5, 8.2, 7.0, 6.5, 7.3, 8.8, 7.6, 8.0, 4.8, 8.6, 6.0, 9.0, 5.0, 7.8, 6.3, 7.2, 8.4, 7.5, 5.1, 8.2, 6.2, 8.8, 4.9, 8.3, 8.1, 4.7, 8.4, 5.2, 8.6, 8.1, 7.5, 5.9, 8.9, 7.9, 5.9, 8.1, 5.0, 8.5, 5.9, 8.7, 5.3, 6.9, 7.7, 5.6, 8.8, 8.1, 4.5, 8.2, 5.5, 9.0, 4.5, 8.3, 5.6, 8.9, 4.6, 8.2, 5.1, 8.6, 5.3, 7.9, 8.1, 6.0, 8.2, 7.7, 7.6, 5.9, 8.0, 4.9, 9.6, 5.3, 7.7, 7.7, 6.5, 8.1, 7.1, 7.0, 8.1, 9.3, 5.3, 8.9, 4.5, 8.6, 5.8, 7.8, 6.6, 7.6, 6.3, 8.8, 5.2, 9.3, 4.9, 5.7, 7.7, 6.8, 8.1, 8.1, 7.3, 5.0, 8.5, 7.4, 5.5, 7.7, 8.3, 8.3, 5.1, 7.8, 8.4, 4.6, 8.3, 5.5, 8.1, 5.7, 7.6, 8.4, 7.7, 8.1, 8.7, 7.7, 5.1, 7.8, 6.0, 8.2, 9.1, 5.3, 7.8, 4.6, 7.7, 8.4, 4.9, 8.3, 7.1, 8.0, 4.9, 7.5, 6.4, 7.6, 5.3, 9.4, 5.5, 7.6, 5.0, 8.2, 5.4, 7.5, 7.8, 7.9, 7.8, 7.8, 7.0, 7.9, 7.0, 5.4, 8.6, 5.0, 9.0, 5.4, 5.4, 7.7, 7.9, 6.4, 7.5, 4.7, 8.6, 6.3, 8.5, 8.2, 5.7, 8.2, 6.7, 7.4, 5.4, 8.3, 7.3, 7.3, 8.8, 8.0, 7.1, 8.3, 5.6, 7.9, 7.8, 8.4, 5.8, 8.3, 4.3, 6.0, 7.5, 8.1, 4.6, 9.0, 4.6, 7.4, 14.0, 15.0]
            }
        ], {
            "showlegend": false,
            "xaxis": {
                "showgrid": true,
                "gridcolor": "lightgrey",
                "showticklabels": true,
                "range": [0.75, 23.25]
            },
            "boxgroupgap": 0,
            "violingap": 0.1,
            "template": "simple_white",
            "boxgap": 0.1,
            "legend": {
                "tracegroupgap": 0,
                "itemdoubleclick": false
            },
            "yaxis": {
                "showgrid": false,
                "gridcolor": "lightgrey",
                "showticklabels": false,
                "range": [null, null]
            },
            "violingroupgap": 0,
            "margin": {
                "l": 50,
                "b": 50,
                "r": 50,
                "t": 50
            }
        }, {
            "editable": false,
            "responsive": true,
            "staticPlot": false,
            "scrollZoom": true
        },
    )
}
</script>
</body>
</html>

It shows:

Image

Guide de contribution

Ouvrir le guide de contribution

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Piste de recherche

Commencez par reproduire les deux exemples HTML fournis avec Plotly 2.3.0, en comparant la mise en page normale du diagramme en violon avec des traces utilisant side="positive" et un violingap non nul. Suivez le chemin de mise en page du diagramme en violon afin de déterminer pourquoi le graphique supérieur est mal positionné et tronqué ; le travail est terminé lorsque les graphiques du côté positif conservent l’écart demandé et que les deux graphiques sont rendus aux bons emplacements.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
javascript
Domaine
data-visualization
Type d'issue
Bug
Difficulté
4/5
Temps estimé
3-5 jours
Activité
À l'abandon
Clarté
Plutôt claire
Accessibilité débutants
35/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.