Comments (7)
Thats suspiciously the same number as there are colors defined. Current HEAD lets you set more than 8 colors via ggplot(...) + scale_colour_manual(values=color_list)
, where color_list is a list of html encoded colors ['#12AB34',...]
.
If that works, this should probably be fixed by throwing an error when the last color is used in color_gen()
(source) and using a palette which has more colors (not sure how...)
from ggpy.
@JanSchulz Good catch. Thats exactly what it was. If you add 32 color to color_list
it plots correctly (although 32 is too many items for the legend, especially since the legend does not wrap in any way).
The simple fix, as you say, is to make a default color pallete with more colors. Because the generators are called later in the ggplot.py
file, i think the only solution is to make the color_list longer or to allow the color_gen
function to sample an arbitrarily large color space.
How does the original ggplot do this? They have a consistent color scheme but I don't know how its mapped.
from ggpy.
They know the number of items and then ask a function in the scale package for the number of colors. This would mean that the current implementation needs to change, as currently color generator does not know the number of values it needs to generate. I will have a look...
from ggpy.
In ggplot.py
the number of uniques are already calculated on line 325 with possible_colors = np.unique(mapping.color)
. I vote for completely replacing thecol_gen
function with color generator that can accept an arbitrary number of values. Let me know if you want me to work on this.
from ggpy.
Yeah this sounds good. I believe it has already been merged.
from ggpy.
Nope: the problem is in https://github.com/yhat/ggplot/blob/master/ggplot/components/colors.py -> it recyles the last color, but the code is doing a reverse coding https://github.com/yhat/ggplot/blob/master/ggplot/ggplot.py#L340 which results that the second round color -> Value
overwrites the first round color -> Value
pair.
The fix is to a) precompute the number of colors needed and b) use a color generator which can give an arbitrary number of colors (that's what ggplot2 does)
OR
don't cycle to colors but throw an error if another color is requested and give a helpful error message how to set more colors.
I suspect that both variants are need for the case when you manually specify colors but they are not enough for the given values.
from ggpy.
fixed in 0.9.3
from ggpy.
Related Issues (20)
- [Feature Request]: Plot directly onto a matplotlib axis HOT 1
- the numbers squeeze on the x-axis or y-axis
- Wrong code
- Is this project dead? HOT 16
- "metaclass conflict" error when using ggplot 0.6.8 with six 1.10.0+
- Import does not work with pandas 0.23.4
- unable to import in jupyter notebook HOT 5
- Warning received when using color aesthetic with geom_point
- Import issue in jupyter notebook
- AttributeError: module 'pandas' has no attribute 'tslib' HOT 35
- Can't facet on variable with more than 9 levels
- facet_grid fail with a category type
- facet_grid repeat x-axis
- pandas sort issue
- How about make it available with dfply?
- Link to an actively developed project called "plotnine" which provides ggplot functionality in python.
- ggplot installs for python3.9.1.0, but import ggplot gets error re pandas attribute tslib HOT 2
- plot multiple geoms on top of each other
- Looking for `ggplot` substitution HOT 2
- Questions about Copilot + Open Source Software Hierarchy
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 ggpy.