4a) Write a Python program to Demonstrate how to Draw a Bar Plot
using Matplotlib.
import numpy as np
import matplotlib.pyplot as plt
# creating the dataset
data = {'C':20, 'C++':15, 'Java':30,
'Python':35}
courses = list(data.keys())
values = list(data.values())
fig = plt.figure(figsize = (10, 5))
# creating the bar plot
plt.bar(courses, values, color ='maroon',
width = 0.4)
plt.xlabel("Courses offered")
plt.ylabel("No. of students enrolled")
plt.title("Students enrolled in different courses")
plt.show()
(or)
import matplotlib.pyplot as plt
country = ['A', 'B', 'C', 'D', 'E']
gdp_per_capita = [45000, 42000, 52000, 49000, 47000]
plt.bar(country, gdp_per_capita)
plt.title('Country Vs GDP Per Capita')
plt.xlabel('Country')
plt.ylabel('GDP Per Capita')
plt.show()
Step 1: Install the Matplotlib package
If you haven’t already done so, install the Matplotlib package in Python
using the command below (under Windows):
pip install matplotlib
You can refer to the following guide for the instructions to install a
package in Python.
Step 2: Gather the data for the bar chart
Next, gather the data for your bar chart.
For illustration purposes, let’s use the following dataset:
country
The ultimate goal is to depict the above data using a bar chart.
Step 3: Capture the data in Python
For this step, capture the above dataset in Python. You can capture this
dataset using lists:
country = ['A', 'B', 'C', 'D', 'E']
gdp_per_capita = [45000, 42000, 52000, 49000, 47000]
Step 4: Create the bar chart in Python using Matplotlib
Finally, you may use the template below to assist you in depicting the
bar chart:
import matplotlib.pyplot as plt
x_axis = ['value_1', 'value_2', 'value_3', ...]
y_axis = ['value_1', 'value_2', 'value_3', ...]
plt.bar(x_axis, y_axis)
plt.title('title name')
plt.xlabel('x_axis name')
plt.ylabel('y_axis name')
plt.show()
For our example, the complete Python code would look as follows:
import matplotlib.pyplot as plt
country = ['A', 'B', 'C', 'D', 'E']
gdp_per_capita = [45000, 42000, 52000, 49000, 47000]
plt.bar(country, gdp_per_capita)
plt.title('Country Vs GDP Per Capita')
plt.xlabel('Country')
plt.ylabel('GDP Per Capita')
plt.show()
import matplotlib.pyplot as plt
country = ['A', 'B', 'C', 'D', 'E']
gdp_per_capita = [45000, 42000, 52000, 49000, 47000]
colors = ['green', 'blue', 'purple', 'brown', 'teal']
plt.bar(country, gdp_per_capita, color=colors)
plt.title('Country Vs GDP Per Capita', fontsize=14)
plt.xlabel('Country', fontsize=14)
plt.ylabel('GDP Per Capita', fontsize=14)
plt.grid(True)
plt.show()
(or)
import numpy as np
import matplotlib.pyplot as plt
# set width of bar
barWidth = 0.25
fig = plt.subplots(figsize =(12, 8))
# set height of bar
IT = [12, 30, 1, 8, 22]
ECE = [28, 6, 16, 5, 10]
CSE = [29, 3, 24, 25, 17]
# Set position of bar on X axis
br1 = np.arange(len(IT))
br2 = [x + barWidth for x in br1]
br3 = [x + barWidth for x in br2]
# Make the plot
plt.bar(br1, IT, color ='r', width = barWidth,
edgecolor ='grey', label ='IT')
plt.bar(br2, ECE, color ='g', width = barWidth,
edgecolor ='grey', label ='ECE')
plt.bar(br3, CSE, color ='b', width = barWidth,
edgecolor ='grey', label ='CSE')
# Adding Xticks
plt.xlabel('Branch', fontweight ='bold', fontsize = 15)
plt.ylabel('Students passed', fontweight ='bold', fontsize = 15)
plt.xticks([r + barWidth for r in range(len(IT))],
['2015', '2016', '2017', '2018', '2019'])
plt.legend()
plt.show()
(or)
import numpy as np
import matplotlib.pyplot as plt
N=5
boys = (20, 35, 30, 35, 27)
girls = (25, 32, 34, 20, 25)
boyStd = (2, 3, 4, 1, 2)
girlStd = (3, 5, 2, 3, 3)
ind = np.arange(N)
width = 0.35
fig = plt.subplots(figsize =(10, 7))
p1 = plt.bar(ind, boys, width, yerr = boyStd)
p2 = plt.bar(ind, girls, width,
bottom = boys, yerr = girlStd)
plt.ylabel('Contribution')
plt.title('Contribution by the teams')
plt.xticks(ind, ('T1', 'T2', 'T3', 'T4', 'T5'))
plt.yticks(np.arange(0, 81, 10))
plt.legend((p1[0], p2[0]), ('boys', 'girls'))
plt.show()
(or)
import matplotlib.pyplot as plt
# Pass the x and y cordinates of the bars to the
# function. The label argument gives a label to the data.
plt.bar([1,3,5,7,9],[5,2,7,8,2], label="Data 1")
plt.legend()
# The following commands add labels to our figure.
plt.xlabel('X values')
plt.ylabel('Height')
plt.title('Vertical Bar chart')
plt.show()
(or)
Horizontal Bar Chart
import matplotlib.pyplot as plt
# Pass the x and y cordinates of the bars to the
# function. The label argument gives a label to the data.
plt.barh(["Cats","Dogs","Goldfish","Snakes","Turtles"],
[5,2,7,8,2], align='center', label="Data 1")
plt.legend()
plt.ylabel('Pets')
plt.xlabel('Popularity')
plt.title('Popularity of pets in the neighbourhood')
plt.show()
4b) Write a Python program to Demonstrate how to Draw a Scatter Plot using Matplotlib
import matplotlib.pyplot as plt
x =[5, 7, 8, 7, 2, 17, 2, 9,4, 11, 12, 9, 6]
y =[99, 86, 87, 88, 100, 86, 103, 87, 94, 78, 77, 85, 86]
plt.scatter(x, y, c ="blue")
# To show the plot
plt.show()
Scatter plots are used to observe relationship between variables and uses dots
to represent the relationship between them. The scatter() method in the
matplotlib library is used to draw a scatter plot. Scatter plots are widely used to
represent relation among variables and how change in one affects the other.
Syntax
The syntax for scatter() method is given below:
matplotlib.pyplot.scatter(x_axis_data, y_axis_data, s=None, c=None,
marker=None, cmap=None, vmin=None, vmax=None, alpha=None,
linewidths=None, edgecolors=None)
The scatter() method takes in the following parameters:
x_axis_data- An array containing x-axis data
y_axis_data- An array containing y-axis data
s- marker size (can be scalar or array of size equal to size of x or y)
c- color of sequence of colors for markers
marker- marker style
cmap- cmap name
linewidths- width of marker border
edgecolor- marker border color
alpha- blending value, between 0 (transparent) and 1 (opaque)
Except x_axis_data and y_axis_data all other parameters are optional and their
default value is None. Below are the scatter plot examples with various
parameters
(or)
import matplotlib.pyplot as plt
# dataset-1
x1 = [89, 43, 36, 36, 95, 10, 66, 34, 38, 20]
y1 = [21, 46, 3, 35, 67, 95, 53, 72, 58, 10]
# dataset2
x2 = [26, 29, 48, 64, 6, 5,36, 66, 72, 40]
y2 = [26, 34, 90, 33, 38, 20, 56, 2, 47, 15]
plt.scatter(x1, y1, c ="pink", linewidths = 2, marker ="s", edgecolor ="green", s = 50)
plt.scatter(x2, y2, c ="yellow",linewidths = 2,marker ="^", edgecolor ="red", s = 200)
plt.xlabel("X-axis")
plt.ylabel("Y-axis")
plt.show()
(or)
import matplotlib.pyplot as plt
price = [2.50, 1.23, 4.02, 3.25, 5.00, 4.40]
sales_per_day = [34, 62, 49, 22, 13, 19]
plt.scatter(price, sales_per_day)
plt.show()
(or)
import matplotlib.pyplot as plt
import numpy as np
price = np.asarray([2.50, 1.23, 4.02, 3.25, 5.00, 4.40])
sales_per_day = np.asarray([34, 62, 49, 22, 13, 19])
profit_margin = np.asarray([20, 35, 40, 20, 27.5, 15])
plt.scatter(x=price, y=sales_per_day, s=profit_margin * 10)
plt.show()
low = (0, 1, 0)
medium = (1, 1, 0)
high = (1, 0, 0)
sugar_content = [low, high, medium, medium, high, low]
plt.scatter(
x=price,
y=sales_per_day,
s=profit_margin * 10,
c=sugar_content,
)
plt.show()
5a) Write a Python program to Demonstrate how to Draw a Histogram Plot using Matplotlib.
import matplotlib.pyplot as plt
import numpy as np
from matplotlib import colors
from matplotlib.ticker import PercentFormatter
# Creating dataset
np.random.seed(23685752)
N_points = 10000
n_bins = 20
# Creating distribution
x = np.random.randn(N_points)
y = .8 ** x + np.random.randn(10000) + 25
# Creating histogram
fig, axs = plt.subplots(1, 1,
figsize =(10, 7),
tight_layout = True)
axs.hist(x, bins = n_bins)
# Show plot
plt.show()
A histogram is basically used to represent data provided in a form of some
groups.It is accurate method for the graphical representation of numerical data
distribution.It is a type of bar plot where X-axis represents the bin ranges while
Y-axis gives information about frequency.
To create a histogram the first step is to create bin of the ranges, then distribute
the whole range of the values into a series of intervals, and count the values
which fall into each of the intervals.Bins are clearly identified as consecutive,
non-overlapping intervals of variables.The matplotlib.pyplot.hist() function is
used to compute and create histogram of x.
Attribute parameter
x array or sequence of array
bins optional parameter contains integer or sequence or strings
density optional parameter contains boolean values
range optional parameter represents upper and lower range of bins
optional parameter used to create type of histogram [bar, barstacked, step,
histtype
stepfilled], default is “bar”
align optional parameter controls the plotting of histogram [left, right, mid]
Attribute parameter
weights optional parameter contains array of weights having same dimensions as x
bottom location of the baseline of each bin
optional parameter which is relative width of the bars with respect to bin
rwidth
width
color optional parameter used to set color or sequence of color specs
optional parameter string or sequence of string to match with multiple
label
datasets
log optional parameter used to set histogram axis on log scale
Let’s create a basic histogram of some random values. Below code creates a
simple histogram of some random values:
Matplotlib provides a range of different methods to customize histogram.
matplotlib.pyplot.hist() function itself provides many attributes with the help of
which we can modify a histogram.The hist() function provide a patches object
which gives access to the properties of the created objects, using this we can
modify the plot according to our will.
5b) Write a Python program to Demonstrate how to Draw a Pie Chart using Matplotlib.
# Import libraries
from matplotlib import pyplot as plt
import numpy as np
# Creating dataset
cars = ['AUDI', 'BMW', 'FORD','TESLA', 'JAGUAR', 'MERCEDES']
data = [23, 17, 35, 29, 12, 41]
# Creating plot
fig = plt.figure(figsize =(10, 7))
plt.pie(data, labels = cars)
# show plot
plt.show()
A Pie Chart is a circular statistical plot that can display only one series of data.
The area of the chart is the total percentage of the given data. The area of
slices of the pie represents the percentage of the parts of the data. The slices of
pie are called wedges. The area of the wedge is determined by the length of the
arc of the wedge. The area of a wedge represents the relative percentage of
that part with respect to whole data. Pie charts are commonly used in business
presentations like sales, operations, survey results, resources, etc as they
provide a quick summary.
Matplotlib API has pie() function in its pyplot module which create a pie chart
representing the data in an array.
Syntax: matplotlib.pyplot.pie(data, explode=None, labels=None, colors=None,
autopct=None, shadow=False)
Parameters:
data represents the array of data values to be plotted, the fractional area of
each slice is represented by data/sum(data). If sum(data)<1, then the data
values returns the fractional area directly, thus resulting pie will have empty
wedge of size 1-sum(data).
labels is a list of sequence of strings which sets the label of each wedge.
color attribute is used to provide color to the wedges.
autopct is a string used to label the wedge with their numerical value.
shadow is used to create shadow of wedge.
(or)
import matplotlib.pyplot as plt
# Defining data for the chart
labels = 'Python', 'C++', 'Ruby', 'Java'
sizes = [215, 130, 245, 210]
colors = ['gold', 'yellowgreen', 'lightcoral', 'lightskyblue']
explode = (0.1, 0, 0, 0) # explode 1st slice
# Plotting the chart
plt.pie(sizes, explode=explode, labels=labels, colors=colors, autopct='%1.1f%
%', shadow=True, startangle=140)
plt.axis('equal')
plt.show()
6a) Write a Python program to illustrate Linear Plotting using Matplotlib.
# importing the required module
import matplotlib.pyplot as plt
# x axis values
x = [1,2,3]
# corresponding y axis values
y = [2,4,1]
# plotting the points
plt.plot(x, y)
# naming the x axis
plt.xlabel('x - axis')
# naming the y axis
plt.ylabel('y - axis')
# giving a title to my graph
plt.title('My first graph!')
# function to show the plot
plt.show()
The code seems self-explanatory. Following steps were followed:
Define the x-axis and corresponding y-axis values as lists.
Plot them on canvas using .plot() function.
Give a name to x-axis and y-axis using .xlabel() and .ylabel() functions.
Give a title to your plot using .title() function.
Finally, to view your plot, we use .show() function.
Method Description
it creates the plot at
the background of
computer, it doesn’t
displays it. We can
plot() also add a label as
it’s argument that
by what name we
will call this plot –
utilized in legend()
it displays the
show()
created plots
xlabel() it labels the x-axis
ylabel() it labels the y-axis
it gives the title to
title()
the graph
it helps to get
access over the all
gca()
the four axes of the
graph
it access the
individual spines or
the individual
gca().spines[‘right/left/top/bottom’].set_visible(True/False)
boundaries and
helps to change
theoir visibility
it decides how the
xticks() markings are to be
made on the x-axis
Method Description
it decides how the
yticks() markings are to be
made on the y-axis
pass a list as it’s
arguments of all the
plots made, if labels
are not explicitly
gca().legend() specified then add
the values in the list
in the same order
as the plots are
made
it is use to write
comments on the
annotate()
graph at the
specified position
whenever we want
the result to be
displayed in a
separate window
we use this
command, and
figure(figsize = (x, y))
figsize argument
decides what will be
the initial size of the
window that will be
displayed after the
run
subplot(r, c, i) it is used to create
multiple plots in the
same figure with r
signifies the no of
rows in the figure, c
signifies no of
columns in a figure
Method Description
and i specifies the
positioning of the
particular plot
it is used to set the
range and the step
set_xticks size of the markings
on x – axis in a
subplot
it is used to set the
range and the step
set_yticks size of the markings
on y – axis in a
subplot
(or)
import matplotlib.pyplot as plt
import numpy as np
# Define X and Y variable data
x = np.array([1, 2, 3, 4])
y = x*2
plt.plot(x, y)
plt.xlabel("X-axis") # add X-axis label
plt.ylabel("Y-axis") # add Y-axis label
plt.title("Any suitable title") # add title
plt.show()
**6b) Write a Python program to illustrate liner plotting with line formatting using Matplotlib.
import matplotlib.pyplot as plt
# Sample data
x = [1, 2, 3, 4, 5]
y = [2, 4, 6, 8, 10]
# Create a basic line plot
plt.plot(x, y, label='Linear Data', linestyle='-', color='b', marker='o', markersize=6)
# Customize the plot
plt.title('Linear Plot with Formatting')
plt.xlabel('X-axis')
plt.ylabel('Y-axis')
plt.grid(True)
plt.legend()
# Show the plot
plt.show()
Explaination - In this program:
1. We import the matplotlib.pyplot module, which provides the functions to
create and customize plots.
2. We define sample data for the x and y coordinates.
3. We use the plt.plot() function to create a line plot. In this function, we
specify the x and y data, set the label for the legend, define the line style
using the linestyle parameter (here, we use a solid line '-'), specify the line
color using the color parameter (blue 'b'), and add markers with marker
(circles 'o').
4. We customize the plot by adding a title, labeling the axes, enabling the grid,
and adding a legend.
5. Finally, we use plt.show() to display the plot.
You can run this program to visualize a basic linear plot with line formatting
using Matplotlib. Make sure you have Matplotlib installed in your Python
environment. You can install it using pip if it's not already installed:
pip install matplotlib
**7a) Write a Python program which explains uses of customizing seaborn plots with Aesthetic
functions.
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt
def sinplot(n=10, flip=1):
x = np.linspace(0, 14, 100)
for i in range(1, n + 1):
plt.plot(x, np.sin(x + i * .5) * (n + 2 - i) * flip)
sinplot()
To switch to seaborn defaults, simply call the set_theme() function.
sns.set_theme()
sinplot()
sns.set_style("white")
sinplot()
Drawing attractive figures is important. When making figures for yourself, as
you explore a dataset, it’s nice to have plots that are pleasant to look at.
Visualizations are also central to communicating quantitative insights to an
audience, and in that setting it’s even more necessary to have figures that catch
the attention and draw a viewer in.
Matplotlib is highly customizable, but it can be hard to know what settings to
tweak to achieve an attractive plot. Seaborn comes with a number of
customized themes and a high-level interface for controlling the look of
matplotlib figures.
(or)
import seaborn as sns
import matplotlib.pyplot as plt
# Load a sample dataset (Iris dataset)
iris = sns.load_dataset("iris")
# Set the style of the plot (e.g., "darkgrid", "whitegrid", "dark", "white", "ticks")
sns.set_style("whitegrid")
# Create a scatter plot with customized aesthetics
sns.scatterplot(x="sepal_length", y="sepal_width", data=iris, hue="species", style="species",
markers=True)
# Customize plot labels and titles
plt.xlabel("Sepal Length (cm)")
plt.ylabel("Sepal Width (cm)")
plt.title("Scatter Plot of Sepal Length vs. Sepal Width")
# Add a legend
plt.legend(title="Species", loc="upper left")
# Adjust plot aesthetics using Seaborn's functions
sns.despine(left=True, bottom=True) # Remove the spines on the left and bottom sides
sns.set_context("paper") # Set the context for text and line scaling
# Show the plot
plt.show()
In this program:
1. We import Seaborn and Matplotlib.
2. We load a sample dataset using sns.load_dataset() (in this case, the Iris
dataset).
3. We set the style of the plot using sns.set_style(). You can choose from
various styles like "darkgrid," "whitegrid," "dark," "white," or "ticks."
4. We create a scatter plot using sns.scatterplot(). We customize aesthetics
by specifying the x and y variables, the data source ( iris), and customize
the plot appearance using hue, style, and markers parameters.
5. We customize labels and titles using standard Matplotlib functions.
6. We add a legend using plt.legend().
7. We use Seaborn's aesthetic functions, sns.despine() to remove spines, and
sns.set_context() to control the context of the plot.
8. Finally, we display the plot using plt.show().
This program demonstrates how to use Seaborn's aesthetic functions to
customize the style and appearance of your plots, making them more
visually appealing and informative. You can further explore Seaborn's
capabilities to fine-tune your plots to suit your specific needs.
8a)Write a Python program to explain working with bokeh line graph using Annotations and Legends.
from bokeh.plotting import figure, output_file, show
p = figure()
x = [x for x in range(1, 11)]
colors = ['red', 'green', 'blue', 'yellow']
for i in range(2, 6):
p.line(x, [val*i for val in x], line_width=2, color=colors[i-2],
alpha=0.8, legend_label='Multiples of {}'.format(i))
p.legend.location = "top_left"
p.legend.click_policy = "hide"
output_file("interactive_legend.html")
show(p)
Bokeh includes several types of annotations to allow users to add supplemental
information to their visualizations. Annotations are used to add notes or more
information about a topic. Annotations can be titles, legends, Arrows, bands,
labels etc.
Adding legends to your figures can help to properly describe and define it.
Hence, giving more clarity. Legends in Bokeh are simple to implement. They
can be basic, automatically grouped, manually mentioned, explicitly indexed
and also interactive.
(or)
from bokeh.plotting import figure, output_file, show
x = [val for val in range(10)]
y = [val for val in range(0, 20, 2)]
output_file("basiclegend.html")
p = figure()
p.line(x, y, legend_label="My Red Line", line_color="red")
p.line(y, x, legend_label="My Orange Line", line_color="orange")
p.line(y[::-1], x, legend_label="My Green Line", line_color="green")
show(p)
9) Write a Python program to draw 3D Plots using Plotly Libraries.
import plotly.express as px
df = px.data.iris()
fig = px.scatter_3d(df, x = 'sepal_width',
y = 'sepal_length',
z = 'petal_width',
color = 'species')
fig.show()
(Iris Dataset is used in this program)
Parameters:
data_frame (DataFrame or array-like or dict) – This argument needs to be
passed for column names (and not keyword names) to be used.
x (str or int or Series or array-like) – Either a name of a column in
data_frame, or a pandas Series or array_like object.
y (str or int or Series or array-like) – Either a name of a column in
data_frame, or a pandas Series or array_like object.
color (str or int or Series or array-like) – Either a name of a column in
data_frame, or a pandas Series or array_like object. Values from this column or
array_like are used to assign color to marks.
Plotly is a Python library that is used to design graphs, especially interactive
graphs. It can plot various graphs and charts like histogram, barplot, boxplot,
spreadplot, and many more. It is mainly used in data analysis as well as
financial analysis. plotly is an interactive visualization library.
3D Scatter plot in Plotly
A scatterplot can be used with several semantic groupings which can help to
understand well in a graph. They can plot two-dimensional graphics that can be
enhanced by mapping up to three additional variables while using the
semantics of hue, size, and style parameters. All the parameter control visual
semantic which are used to identify the different subsets. Using redundant
semantics can be helpful for making graphics more accessible. It can be
created using the scatter_3d function of plotly.express class.
(or)
import plotly.graph_objects as go
import numpy as np
x = np.outer(np.linspace(-2, 2, 30), np.ones(30))
y = x.copy().T
z = np.cos(x ** 2 + y ** 2)
fig = go.Figure(data=[go.Surface(x=x, y=y, z=z)])
fig.show()
10 a) Write a Python program to draw Time Series using Plotly Libraries.
# Using plotly.express
import plotly.express as px
df = px.data.stocks()
fig = px.line(df, x='date', y="GOOG")
fig.show()
Time Series using Axes of type date
Time series can be represented using either plotly.express functions
(px.line, px.scatter, px.bar etc) or plotly.graph_objects charts objects
(go.Scatter, go.Bar etc). For more examples of such charts, see the documentation of line and
scatter plots or bar charts.
For financial applications, Plotly can also be used to create Candlestick charts and OHLC charts,
which default to date axes.
Plotly auto-sets the axis type to a date format when the corresponding data are either ISO-formatted
date strings or if they're a date pandas column or datetime NumPy array.
(or)
# Using graph_objects
import plotly.graph_objects as go
import pandas as pd
df = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/finance-charts-apple.csv')
fig = go.Figure([go.Scatter(x=df['Date'], y=df['AAPL.High'])])
fig.show()
10 b) Write a Python program for creating Maps using Plotly Libraries.
import plotly.express as px
df = px.data.election()
geojson = px.data.election_geojson()
fig = px.choropleth(df, geojson=geojson, color="Bergeron",
locations="district", featureidkey="properties.district",
projection="mercator"
fig.update_geos(fitbounds="locations", visible=False)
fig.update_layout(margin={"r":0,"t":0,"l":0,"b":0})
fig.show()
If the GeoJSON you are using either does not have an id field or you wish to use one of the keys in
the properties field, you may use the featureidkey parameter to specify where to match the
values of locations.
To use them together, we
set locations to district and featureidkey to "properties.district". The color is
set to the number of votes by the candidate named Bergeron.
(or)
import plotly.express as px
import pandas as pd
# Import data from GitHub
data = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/
gapminder_with_codes.csv')
# Create basic choropleth map
fig = px.choropleth(data, locations='iso_alpha', color='gdpPercap', hover_name='country',
projection='natural earth', title='GDP per Capita by Country')
fig.show()
This code imports the necessary libraries, plotly.express and pandas, to create a
choropleth map. • It then reads in data from a CSV file hosted on GitHub using
pd.read_csv(). • The px.choropleth() function is used to create the choropleth map.
• It takes in the data DataFrame as the first argument, and then specifies the
locations column, iso_alpha, which contains the ISO alpha-3 codes for each country. •
The color argument is set to gdpPercap, which is the column containing the GDP per
capita data. • The hover_name argument is set to country, which is the column
containing the country names. • The projection argument is set to natural earth,
which is the type of map projection to use. • Finally, the title argument is set to GDP
per Capita by Country. • The fig.show() function is then called to display the
choropleth map.