Data Visualizations in Python and R

Python:

  1. Matplotlib:

  • Matplotlib is a widely-used plotting library in Python. It provides a flexible and comprehensive set of plotting functions.
  • Simple Example:

import matplotlib.pyplot as plt


x = [1, 2, 3, 4, 5]

y = [2, 4, 6, 8, 10]


plt.plot(x, y)

plt.xlabel('X-axis')

plt.ylabel('Y-axis')

plt.title('Simple Line Plot')

plt.show()

2. Seaborn:

  • Seaborn is built on top of Matplotlib and provides a high-level interface for creating attractive and informative statistical graphics.
  • Simple Example:

import seaborn as sns


tips = sns.load_dataset('tips')

sns.barplot(x='day', y='total_bill', data=tips)

3. Plotly:

  • Plotly is an interactive visualization library that produces high-quality and interactive plots. It offers a wide range of chart types and customization options.
  • Simple Example:

import plotly.express as px


df = px.data.iris()

fig = px.scatter(df, x="sepal_width", y="sepal_length", color="species")

fig.show()

4. Bokeh:

  • Bokeh is another interactive visualization library that targets modern web browsers for presentation. It supports both simple and complex visualizations.
  • Simple Example:

from bokeh.plotting import figure, output_file, show


x = [1, 2, 3, 4, 5]

y = [2, 4, 6, 8, 10]


output_file("line_plot.html")

p = figure(title="Simple Line Plot", x_axis_label='X-axis', y_axis_label='Y-axis')

p.line(x, y)

show(p)



***************************************************************************

R:

  1. ggplot2:

  • ggplot2 is a widely-used data visualization library in R that implements the grammar of graphics. It provides a layered approach to creating plots.
  • Simple Example:

library(ggplot2)


data <- data.frame(x = c(1, 2, 3, 4, 5), y = c(2, 4, 6, 8, 10))

ggplot(data, aes(x = x, y = y)) + geom_line() +

?xlab("X-axis") + ylab("Y-axis") +

?ggtitle("Simple Line Plot")

2. lattice:

  • lattice is a powerful and flexible library for creating conditioned plots in R. It allows for easy creation of trellis plots, which are multi-panel displays.
  • Simple Example:

library(lattice)


data <- data.frame(x = c(1, 2, 3, 4, 5), y = c(2, 4, 6, 8, 10))

xyplot(y ~ x, data = data, type = "b",

????xlab = "X-axis", ylab = "Y-axis",

????main = "Simple Line Plot")

3. plotly:

  • Plotly is also available for R and provides interactive and dynamic visualizations with a wide range of options. It supports various types of charts.
  • Simple Example:

library(plotly)


data <- iris

fig <- plot_ly(data, x = ~Petal.Width, y = ~Petal.Length, color = ~Species, mode = "markers")

fig

4. ggvis:

  • ggvis is an interactive data visualization package for R based on the principles of ggplot2. It supports interactive features like tooltips and dynamic filtering.
  • Simple Example:

library(ggvis)


data <- data.frame(x = c(1, 2, 3, 4, 5), y = c(2, 4, 6, 8, 10))

data %>% ggvis(~x, ~y) %>% layer_lines() %>%

?add_axis("x", title = "X-axis") %>%

?add_axis("y", title = "Y-axis") %>%

?set_options(width = 500, height = 300)









要查看或添加评论,请登录

Vishwajit Sen的更多文章

  • Exploring new opportunities in Data Science

    Exploring new opportunities in Data Science

    Career Objective: Dedicated Data Science and Machine Learning Expert with a passion for driving innovation across…

    1 条评论
  • Technical indicators in the stock market:

    Technical indicators in the stock market:

    Technical indicators in the stock market are mathematical calculations based on historical price, volume, or open…

  • Preparing data for a recommendation system??

    Preparing data for a recommendation system??

    Preparing data for a recommendation system involves organizing and structuring the data in a format that is suitable…

  • Pooling and Padding in CNN??

    Pooling and Padding in CNN??

    Pooling is a down-sampling operation commonly used in convolutional neural networks to reduce the spatial dimensions…

  • What is Computer Vision??

    What is Computer Vision??

    Computer vision is a multidisciplinary field that enables machines to interpret, analyze, and understand the visual…

  • PRUNING in Decision Trees

    PRUNING in Decision Trees

    Pruning is a technique used in decision tree algorithms to prevent overfitting and improve the generalization ability…

    1 条评论
  • "NO" need to check for multicollinearity or remove correlated variables explicitly when using decision trees.

    "NO" need to check for multicollinearity or remove correlated variables explicitly when using decision trees.

    Multicollinearity is a phenomenon in which two or more independent variables in a regression model are highly…

  • MLOps concepts

    MLOps concepts

    MLOps, short for Machine Learning Operations, is a set of practices and tools that combines machine learning (ML) and…

  • Python library & It's Uses

    Python library & It's Uses

    NumPy: Numerical computing library for arrays, matrices, and mathematical functions. Pandas: Data manipulation and…

  • How much do you know about Weight initialization in Neural Networks ??

    How much do you know about Weight initialization in Neural Networks ??

    Weight initialization is a crucial step in training neural networks. It involves setting the initial values of the…

    1 条评论

社区洞察

其他会员也浏览了