1

Is it possible to rotate the labels resulting from faceting in Python's implementation of ggplot? Here is an example of what I have in mind:

import pandas as pd
from ggplot import *

df = pd.DataFrame({'id': [1,2,3,4], 
               'left' :  [1,2,3,4],
               'right' : [2,1,4,3],
               'b' : ['alfa','beta','alfa','beta'], 
               'c' : ['one', 'one', 'two', 'two']})

dfm = pd.melt(df, id_vars=['b','c'], value_vars=['left','right'])

print(dfm)

      b    c variable  value
0  alfa  one     left      1
1  beta  one     left      2
2  alfa  two     left      3
3  beta  two     left      4
4  alfa  one    right      2
5  beta  one    right      1
6  alfa  two    right      4
7  beta  two    right      3


ggplot(dfm, aes(x='variable', y='value')) + \
    geom_point() + \
    facet_grid('b','c') + \
    theme(strip_text_y = element_text(angle = 0))

resulting plot

I would like to have the labels alpha and beta rotated horizontally, but I don't know how to achieve this. Thank you in advance.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.