Skip to content

use geom_segment when scale x is datetime #88

Description

@gaorongchao

if the scale x is not datetime,it work

from plotnine import * 
from plotnine.data import *
import datetime

p = ggplot(economics,aes(x='pop',y='pce'))
(p + geom_line()
  + geom_segment(aes(x=240000,xend=240000,y=0,yend=12500)))

The flow doesnot work

from mizani.breaks import date_breaks
from mizani.formatters import date_format

p = ggplot(economics,aes(x='date',y='pce'))
(p + geom_line()
   + geom_segment(aes(x=datetime.datetime.strptime('1970-01-01','%Y-%m-%d'),xend=datetime.datetime.strptime('1970-01-01','%Y-%m-%d'),y=0,yend=12500)) 
   + scale_x_datetime(breaks=date_breaks('10 years'),labels=date_format('%Y')))

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions