Comments (4)
On second thought... even though this matplotlib example is weird it probably makes more sense to assign identical labels to each line rather than raising an error. That way users can easily assign labels, but prevent repeated legend entries by (e.g.) manually passing a single line handle to legend()
. I'll re-open
from proplot.
Makes sense. Maybe that should be the default behavior when label
is used instead of labels
(currently they are aliases)? For now here's a clumsy workaround:
import numpy as np
import proplot as pplt
state = np.random.RandomState(51423)
x = np.linspace(0, 5, 20)
y1 = x[:, np.newaxis] + state.rand(20, 10)
y2 = x[::-1, np.newaxis] + state.rand(20, 10)
fig, ax = pplt.subplots()
ax.plot(y1, c='r', label=['y1'] + 9 * [None])
ax.plot(y2, c='b', label=['y2'] + 9 * [None])
ax.legend()
from proplot.
On second thought, this might cause unexpected behavior. We need to specify a color (and other properties) for the group of lines. If we pass a single label without specifying a color, it won't know which color to use for the legend.
We could use the property of the first line, but I don't know if this is a good idea.
from proplot.
Hmm yeah I can see that. And actually this is matplotlib's default behavior :/... not sure if any better than current proplot behavior of raising an error. Think I'll close then
import numpy as np
import matplotlib.pyplot as plt
state = np.random.RandomState(51423)
x = np.linspace(0, 5, 20)
y1 = x[:, np.newaxis] + state.rand(20, 10)
y2 = x[::-1, np.newaxis] + state.rand(20, 10)
fig, ax = plt.subplots()
ax.plot(y1, c='r', label='y1')
ax.plot(y2, c='b', label='y2')
ax.legend()
from proplot.
Related Issues (20)
- unexpected minor ticks in colorbar
- Hide datetime minorticks?
- add more color blind-friendly default color cycle
- bug: cannot set equal aspect for log scale HOT 1
- Support for plotting distribution with different number of samples HOT 6
- How to set the order of 'abc'? HOT 1
- Bug: xticklabels overwrites xminorticks setting HOT 3
- Cannot pass norm argument to hist2d
- Any timeline for a relase that supports matplotlib >=3.5?
- Proplot changes names of colormaps to lowercase, breaking `matplotlib.pyplot.get_cmap`
- MatplotlibDeprecationWarning with unexpected argument for savefig() HOT 3
- proplot can't plot string like datetime
- Inset_axes zooms doesn't show lines
- Trying to make a line over contourf returns TypeError HOT 5
- TypeError: tricontourf() takes 4 positional arguments but 5 were given
- Option for adding errorbar legend
- Nonsticky bounds
- How to use proplot in MATLAB HOT 1
- path effects not pretty
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from proplot.