The position
parameter in scale_x_(), scale_y_()
functions controls position of the axis:
import pandas as pd
from lets_plot import *
LetsPlot.setup_html()
LetsPlot.set_theme(theme_grey())
df = pd.read_csv('https://raw.githubusercontent.com/JetBrains/lets-plot-docs/master/data/iris.csv')
df.head(3)
sepal_length | sepal_width | petal_length | petal_width | species | |
---|---|---|---|---|---|
0 | 5.1 | 3.5 | 1.4 | 0.2 | setosa |
1 | 4.9 | 3.0 | 1.4 | 0.2 | setosa |
2 | 4.7 | 3.2 | 1.3 | 0.2 | setosa |
p = (ggplot(df) + geom_point(aes("sepal_width", "sepal_length", color="species"), size=5)
+ scale_color_brewer(palette="Set1")
)
p
position="right"
¶p + scale_y_continuous("Sepal Length", position="right")
position="top"
¶p + scale_x_continuous(position="top")
position="both"
¶(p
+ scale_x_continuous("Sepal Width", position="both")
+ scale_y_continuous("Sepal Length", position="both")
)
(p
+ scale_x_continuous("Sepal Width", position="both")
+ scale_y_continuous("Sepal Length", position="both")
+ coord_fixed()
)