Code Monkey home page Code Monkey logo

Comments (8)

jankatins avatar jankatins commented on August 17, 2024

Could you add the code which produces the error (and the wrong plot)? There is non visible in the bugreport.

from ggpy.

eduardflorinescu avatar eduardflorinescu commented on August 17, 2024

Updated issue with the requested info.

from ggpy.

zachcp avatar zachcp commented on August 17, 2024

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.

zachcp avatar zachcp commented on August 17, 2024

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.

zachcp avatar zachcp commented on August 17, 2024

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.

eduardflorinescu avatar eduardflorinescu commented on August 17, 2024

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.

naught101 avatar naught101 commented on August 17, 2024

Here's the same graph as above, with a more recent version of ggplot:

python

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.

eduardflorinescu avatar eduardflorinescu commented on August 17, 2024

@naught101 Thanks for updating, I think the spectrum color-bar is the greatest visual inconsistency.

from ggpy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.