Giter VIP home page Giter VIP logo

Comments (5)

santosjorge avatar santosjorge commented on July 30, 2024

Hey Chris,

Currently the way to do this would be:

fig=cf.tools.figures(df,[{'kind':'bar'},{'kind':'scatter','mode':'markers','color':'red'}])
cf.iplot(fig)

cf.tools.figures takes a DataFrame and then a list of dictionaries with all the specs.

This works today. But of course it could be enhanced if you think it could be made easier. I think passing the 'kind' types in a dict is intuitive enough, the problem is when you start passing specs. That is why I went down this way, but let me know what you think.

from cufflinks.

chriddyp avatar chriddyp commented on July 30, 2024

got it! that looks like a good solution for now!

from cufflinks.

chriddyp avatar chriddyp commented on July 30, 2024

hey @santosjorge - I'm just giving this a try today. Since cf.tools.figures returns a list of figures, it seems like I need to merge the figures before I plot them, e.g.

df = cf.datagen.lines(2, 5)

figs = cf.tools.figures(df, [
    {'kind': 'bar'},
    {'kind': 'scatter', 'mode': 'markers'}
])

fig = {'data': [], 'layout': {}}
for f in figs:
    fig['data'].extend(f['data'])
    fig['layout'].update(f['layout'])

I'm not sure if the solution is for cf.tools.figures to return a single, merged figure or for another cf.tools function like cf.tools.create_figure, or the original suggestion of letting df.iplot accept values as an array. Thoughts?

from cufflinks.

santosjorge avatar santosjorge commented on July 30, 2024

Hey Chris,
cf.figures returns a single figure already merged. You should be able to do

df = cf.datagen.lines(2, 5)

figs = cf.tools.figures(df, [
    {'kind': 'bar'},
    {'kind': 'scatter', 'mode': 'markers'}
])

cf.iplot(figs)

without any issue.

But I'll work in a new function to do accept values as an array. I will try first with df.iplot, I am just concerned about overloading it too much. I'll get back to you on this.

from cufflinks.

RubenPhy avatar RubenPhy commented on July 30, 2024

Hi.
I am trying to have different kind of plots with different data and with a secondary axis. But in the last step of having a different axis I have had problems. How I could solve this step?
I try adding a secondary y axis, but it doesn't work.

df = pd.DataFrame({'y1': [3, 1, 5], 'y2': [30, 50, 20], 'y3': [300, 500, 200]}, index=[1, 2, 3])
fig=cf.tools.figures(df,[{'kind':'bar','keys':['y2','y1']},
                         {'kind':'scatter','keys':['y3'],'mode':'markers','color':'red',
                         'secondary_y':['y3']}])

Version '0.17.0'
Thank you so much in advance.

from cufflinks.

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.