Skip to content

geom_segment with discrete y-axis and NA values #523

Closed

Description

@atrejut

Description

See the below examples. If there are None values present in the key column of the dataframe, the y-axis of the plot is extended by numeric values (1, 2, 3) in addition to the expected expected entries ('foo', 'bar', 'bazz').
If the None-value is converted to a string everything works as expected.

Sample code to reproduce

data = pd.DataFrame(dict(
    key=['foo', 'foo', 'bar', None, 'bazz'],
    start = [pd.Timestamp(x) for x in ['2021-01-01', '2021-02-01', '2021-03-01', '2021-04-01', '2021-05-01']],
    end = [pd.Timestamp(x) for x in ['2021-01-15', '2021-02-15', '2021-03-15', '2021-04-15', '2021-05-15']],
    color = ['arg', 'brg', 'brg', 'zrg', 'arg'])
)

aes = {
    'x': 'start', 'xend': 'end',
    'y': 'key', 'yend': 'key',
    'color': 'color',
}


plot = p9.ggplot(data, p9.aes(**aes))
plot += p9.geom_segment(size=6, alpha=0.7)
plot

image

Activity

  1. added a commit that references this issue on Mar 31, 2022
    83fba1a
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