matplotlib / matplotlib/matplotlib

Add ability to add QuiverKey object to Legend

Aberta
#16,664 2 comentários 0 reações 0 responsáveis Ver no GitHub

Ninguém assumiu esta issue ainda.

New feature topic: arrow topic: legend
Linguagem predominante
Python
Estrelas
23.2k
Forks
8.5k
Merge médio
1d 6h
PRs com merge (30d)
66

Descrição

Feature Request

Feature summary
I'd like to be able to add the QuiverKey object to the legend as a handle. So the length of the arrow in the legend is meaningful to the quivers on the plot, but so it can be displayed in a tidy way with more mixed plot types. This was mentioned on another issue, but I don't think it's actually been implemented.

Code for reproduction

from matplotlib.patches import Patch
import matplotlib.pyplot as plt
import numpy as np

fig, ax = plt.subplots()

X = np.arange(-10, 10, 1)
Y = np.arange(-10, 10, 1)
U, V = np.meshgrid(X, Y)

q = ax.quiver(X, Y, U, V)

qk = ax.quiverkey(q, 0.9,0.8, U=10, label='QK length = 10', labelpos='E')

legend_elements = [
    Patch(facecolor="red", edgecolor="black", label="First Element"),
    qk
]

ax.legend(handles=legend_elements)

plt.show()

Actual outcome

/opt/conda/envs/py37/lib/python3.7/site-packages/ipykernel_launcher.py:20: UserWarning: Legend does not support <matplotlib.quiver.QuiverKey object at 0x7fcf101d7b00> instances.
A proxy artist may be used instead.
See: http://matplotlib.org/users/legend_guide.html#creating-artists-specifically-for-adding-to-the-legend-aka-proxy-artists

Expected outcome
Have the quiverkey as another element in the legend box with my other proxies. If I create a proxy as the error suggests, it will lose it's meaningful length and therefore it's value as a "key".

Matplotlib version

  • Operating system: Linux Mint
  • Matplotlib version: 3.1.2
  • Matplotlib backend: module://ipykernel.pylab.backend_inline
  • Python version: 3.7.3

Guia de contribuição

Abrir o guia de contribuição

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Direção de pesquisa

Comece executando a reprodução em Python fornecida e inspecione o tratamento de legendas do Matplotlib juntamente com o objeto QuiverKey. O recurso estará concluído quando um QuiverKey puder ser passado como um identificador de legenda sem um aviso e o comprimento significativo de sua seta for preservado junto com as outras entradas da legenda.

Escrita pelo modelo de indexação a partir do texto da issue.

Avaliação

Stack de tecnologia
python
Domínio
data-visualization
Tipo de issue
Funcionalidade
Dificuldade
4/5
Tempo estimado
3-5 dias
Status de atividade
Estagnada
Clareza
Razoavelmente clara
Facilidade para iniciantes
35/100

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.