Coder Social home page Coder Social logo

Comments (4)

votti avatar votti commented on September 24, 2024

I think this is the 'correct' or at least the behaviour consistent with R ggplot2. coord_cartesian (not scale_y_continous) should be used instead to not ignore the data outside the provided limits, but rather just 'zoom in' the axes:
http://ggplot2.tidyverse.org/reference/coord_cartesian.html

from plotnine.

aflueckiger avatar aflueckiger commented on September 24, 2024

@votti Thanks for pointing out that I used the wrong statement to adjust the visible scale. However, the issue is still present even when using the coord_cartesian syntax.
This code produces the plot below that doesn't start at zero yet.

plot = (ggplot(df_docs_model) +
    aes(x='quarter_num', y='value', color='factor(topic)') +
    geom_smooth(method='loess', span = 0.1, alpha=0.2, size=2, show_legend=False) + #  
    scale_x_continuous(breaks=list(range(1994, 2019, 2))) +
    scale_y_continuous(breaks=[y / 100 for y in range(0, 15, 1)]) +
    coord_cartesian(ylim = (0, 0.14)) +
    facet_wrap('~topic'))

fig_coord_cart

Is this feature already properly implemented in plotnine? I'm asking this again since the respective ggplot2 documentation, posted by votti, explicitly specifies this use case.

from plotnine.

has2k1 avatar has2k1 commented on September 24, 2024

@votti is right. However, there was a bug in coord_cartesian when setting the ylim. It was fixed in #30.

Try the development version

pip install git+https://github.com/has2k1/plotnine.git

to see if it works for you.

from plotnine.

aflueckiger avatar aflueckiger commented on September 24, 2024

It worked fine with the current development version. I appreciate your help. Thanks.

from plotnine.

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.