How to plot a simple x and y chart in R?
MACHINE LEARNING RECIPES DATA CLEANING PYTHON DATA MUNGING PANDAS CHEATSHEET     ALL TAGS

# How to plot a simple x and y chart in R?

This recipe helps you plot a simple x and y chart in R

0

## Recipe Objective

Scatter plot is the simplest chart which uses cartesian coordinates to display the relation between two variables x and y. It is used to find any trend between the two variables.

This recipe demonstrates how to plot a simple x,y chart in R

## STEP 1: Creating Example data

We will use an example of no of schools established in 2 states between 1970 and 2014

``` # years year_x = c('1970','1980', '1990', '2000', '2013', '2014') ​ ​ #no of schools in state1 corresponding to a particular year state_y1 = c(15, 30, 60, 120, 240, 300) ```

## STEP 2: Plotting a basic scatter chart with multiple points on the graph

Using plot() function to plot the number of schools vs Year for a state

Syntax:

plot(X, y, type, col, main, xlab, ylab)

where,

1. X = x values
2. Y = y values
3. col = colour of the line
4. main = title of the graph
5. xlab = xlabel of the plot
6. ylab = ylabel of the plot
``` plot(year_x, state_y1, col = 'red', main = 'Number of schools vs Year', xlab = 'Year', ylab = 'Number of Schools') ```

#### Relevant Projects

##### Time Series Forecasting with LSTM Neural Network Python
Deep Learning Project- Learn to apply deep learning paradigm to forecast univariate time series data.

##### Human Activity Recognition Using Multiclass Classification in Python
In this human activity recognition project, we use multiclass classification machine learning techniques to analyse fitness dataset from a smartphone tracker.

##### NLP and Deep Learning For Fake News Classification in Python
In this project you will use Python to implement various machine learning methods( RNN, LSTM, GRU) for fake news classification.

##### Build a Music Recommendation Algorithm using KKBox's Dataset
Music Recommendation Project using Machine Learning - Use the KKBox dataset to predict the chances of a user listening to a song again after their very first noticeable listening event.

##### Predict Credit Default | Give Me Some Credit Kaggle
In this data science project, you will predict borrowers chance of defaulting on credit loans by building a credit score prediction model.

##### Loan Eligibility Prediction in Python using H2O.ai
In this loan prediction project you will build predictive models in Python using H2O.ai to predict if an applicant is able to repay the loan or not.

##### Customer Churn Prediction Analysis using Ensemble Techniques
In this machine learning churn project, we implement a churn prediction model in python using ensemble techniques.

##### Credit Card Fraud Detection as a Classification Problem
In this data science project, we will predict the credit card fraud in the transactional dataset using some of the predictive models.

##### Mercari Price Suggestion Challenge Data Science Project
Data Science Project in Python- Build a machine learning algorithm that automatically suggests the right product prices.

##### Customer Market Basket Analysis using Apriori and Fpgrowth algorithms
In this data science project, you will learn how to perform market basket analysis with the application of Apriori and FP growth algorithms based on the concept of association rule learning.