#!/usr/bin/env python # coding: utf-8 # # Axis Position # # The `position` parameter in `scale_x_(), scale_y_()` functions controls position of the axis: # # - 'left', 'right' or 'both' for y-axis; # - 'top', 'bottom' or 'both' for x-axis. # # In[1]: import pandas as pd from lets_plot import * # In[2]: LetsPlot.setup_html() LetsPlot.set_theme(theme_grey()) # In[3]: df = pd.read_csv('https://raw.githubusercontent.com/JetBrains/lets-plot-docs/master/data/iris.csv') df.head(3) # #### 1. Default Axis Position # # In[4]: p = (ggplot(df) + geom_point(aes("sepal_width", "sepal_length", color="species"), size=5) + scale_color_brewer(palette="Set1") ) p # #### 2. `position="right"` # In[5]: p + scale_y_continuous("Sepal Length", position="right") # #### 3. `position="top"` # In[6]: p + scale_x_continuous(position="top") # #### 4. `position="both"` # In[7]: (p + scale_x_continuous("Sepal Width", position="both") + scale_y_continuous("Sepal Length", position="both") ) # ##### 4.1 Lets use equal units on the X-axis and on the Y-axis. # In[8]: (p + scale_x_continuous("Sepal Width", position="both") + scale_y_continuous("Sepal Length", position="both") + coord_fixed() )