Comments (8)
Could you add the code which produces the error (and the wrong plot)? There is non visible in the bugreport.
from ggpy.
Updated issue with the requested info.
from ggpy.
Looks like the column is being treated as a text column and not numerical so it is getting a discrete scale instead of a continuous one. i would check your pandas dataframe and see if it is using the first line as a column or if it is making the entire column into a string.
something like:
spowd = pd.read_csv(INPUT_FILE, header=TRUE)
from ggpy.
This is a mishandling of continuous color scales. The error is reproducible here:
from ggplot import *
ggplot(diamonds, aes('carat', 'price', color='price')) + \
geom_point(alpha=1/20.) + \
ylim(0, 20000)
#line 334 ggplot.oy
if 'color' in mapping._get_numeric_data().columns:
mapping['cmap'] = self.colormap
I don't see mapping.cmap
get used again. I think the colormap needs to be put back into the mapping.color
value to be picked up by ggplot.__repr__
. This would require using the values held in 'mapping.color' to use the 'cmap'. I'm not sure how to do this. Is anyone familiar with matplotlib colormaps?
from ggpy.
walking through the code, I think the color mapping is fine. The color differences in python vs. R are due to an inverted scale and a legend that is displayed as quantile instead of as a continuous variable. I don't think either of those have been implemented yet in this version of ggplot. Your specific error I couldn't track down but it believe it is due to some cross talk between aes
groupings. Coloring by voltage, by itse,f for example , works jsut fine. It is only when bothcolor
and shape
are used that there is an issue:
## Single Values: These all wor
ggplot(aes(x='TIME', y='Watts', color="Volts", ymin=YMIN, ymax=YMAX), data=spowd) + geom_point()
ggplot(aes(x='TIME', y='Watts', color="category", ymin=YMIN, ymax=YMAX), data=spowd) + geom_point()
ggplot(aes(x='TIME', y='Watts', shape="Volts", ymin=YMIN, ymax=YMAX), data=spowd) + geom_point()
ggplot(aes(x='TIME', y='Watts', shape="category", ymin=YMIN, ymax=YMAX), data=spowd) + geom_point()
#Shape and Color where Color is category: These work
ggplot(aes(x='TIME', y='Watts', shape="category", color="category", ymin=YMIN, ymax=YMAX), data=spowd) + geom_point()
ggplot(aes(x='TIME', y='Watts', shape="Volts", color="category", ymin=YMIN, ymax=YMAX), data=spowd) + geom_point()
## Shape and Color where color is Volt. These fail
ggplot(aes(x='TIME', y='Watts', shape="category", color="Volts", ymin=YMIN, ymax=YMAX), data=spowd) + geom_point()
ggplot(aes(x='TIME', y='Watts', shape="Volts", color="Volts", ymin=YMIN, ymax=YMAX), data=spowd) + geom_point()
The plot_layer
function is only being passed a single color value for the last two. Why? I'm not sure why the color values are correctly assigned in most cases but not the last two.
from ggpy.
The below case where shape="Volts"
doesn't work for me:
ggplot(aes(x='TIME', y='Watts', shape="Volts", color="category", ymin=YMIN, ymax=YMAX), data=spowd) + geom_point()
gives:
Traceback (most recent call last):
File "test_aestheticmappings.py", line 39, in <module>
ylab("Watts")
File "C:\PYTHON27\lib\site-packages\ggplot\ggplot.py", line 206, in __repr__
for layer in self._get_layers(self.data):
File "C:\PYTHON27\lib\site-packages\ggplot\ggplot.py", line 318, in _get_layers
mapping['marker'] = mapping['shape'].replace(shape_mapping)
File "C:\PYTHON27\lib\site-packages\pandas\core\series.py", line 2741, in replace
_rep_dict(result, to_replace)
File "C:\PYTHON27\lib\site-packages\pandas\core\series.py", line 2735, in _rep_dict
_rep_one(rs, sset, d)
File "C:\PYTHON27\lib\site-packages\pandas\core\series.py", line 2715, in _rep_one
com._maybe_upcast_putmask(s.values,mask,v,change=change)
File "C:\PYTHON27\lib\site-packages\pandas\core\common.py", line 813, in _maybe_upcast_putmask
return changeit()
File "C:\PYTHON27\lib\site-packages\pandas\core\common.py", line 767, in changeit
om = other[mask]
TypeError: only integer arrays with one element can be converted to an index
from ggpy.
Here's the same graph as above, with a more recent version of ggplot:
Main problems remaining:
- Axis ticks go right to the ends of the axis (uneccessary rounding, also makes it more likely for x/y axis ticks to clash).
- There isn't a continuous colourbar
- The default colourscheme is inverted, and the contrast is too high
Everything else is looking pretty good though :)
from ggpy.
@naught101 Thanks for updating, I think the spectrum color-bar is the greatest visual inconsistency.
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.