0% found this document useful (0 votes)
21 views

Conversion Guide R Python Data Visualization

This document provides a summary of converting data visualization between R and Python. It lists the basic plot types in R and their equivalent commands in Python, including scatter plots, line plots, bar charts, box plots, and heatmaps. It also describes how to add additional elements to plots like vertical and horizontal lines, rectangles, and text. Parameters for the plotting commands that control aspects like color, size, transparency, and line style are also summarized.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views

Conversion Guide R Python Data Visualization

This document provides a summary of converting data visualization between R and Python. It lists the basic plot types in R and their equivalent commands in Python, including scatter plots, line plots, bar charts, box plots, and heatmaps. It also describes how to add additional elements to plots like vertical and horizontal lines, rectangles, and text. Parameters for the plotting commands that control aspects like color, size, transparency, and line style are also summarized.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

15.

003 Software Tools — Data Science Afshine Amidi & Shervine Amidi

Conversion Guide between R and Python: Advanced features

Data visualization r Additional elements – We can add objects on the plot with the following commands:

Type R Command Python Command


Afshine Amidi and Shervine Amidi
geom_vline( ax.axvline(
August 21, 2020 x, ymin, ymax, color,
xintercept, linetype
linewidth, linestyle
) )
General structure Line
r Basic plots – The main basic plots are summarized in the table below:
geom_hline( ax.axhline(
Type R Command Python Command y, xmin, xmax, color,
yintercept, linetype
linewidth, linestyle
geom_point( sns.scatterplot( ) )
Scatter
x, y, params x, y, params
plot
) )
geom_rect( ax.axvspan(
Rectangle xmin, xmax, ymin, ymax xmin, xmax, ymin, ymax
geom_line( sns.lineplot(
Line ) )
x, y, params x, y, params
plot
) )
geom_text( ax.text(
Text x, y, label, hjust, vjust x, y, s, color
geom_bar( sns.barplot(
Bar ) )
x, y, params x, y, params
chart
) )

Box geom_boxplot( sns.boxplot(


plot x, y, params x, y, params
) )

geom_tile( sns.heatmap(
Heatmap x, y, params x, y, params
) )

where the meaning of parameters are summarized in the table below:

Command Description Use case


color / hue Color of a line / point / border ’red’
fill Color of an area ’red’
size Size of a line / point 4
linetype Shape of a line ’dashed’
alpha Transparency, between 0 and 1 0.3

Massachusetts Institute of Technology 1 https://www.mit.edu/~amidi

You might also like