Explanation of Solution
Function “xticks()”:
- • Function “xticks()” displays the customized tick mark labels along the X axis.
- • This function sets the X limits of the current location with the tick label.
Syntax:
The “xticks()” function has the below format.
#Customize the tick marks along the X axis
plt.xticks(locations, labels)
Explanation:
Here,
- • “xticks()” is the function that customizes the tick marks along the X axis.
- • The variables “locations” and “labels” are one-dimensional list that specifies the tick mark locations and its corresponding labels.
Example program:
The below example shows how to use the “xticks()” function in Python.
#Import the files
import matplotlib.pyplot as plt
#Function definition
def main():
#Define the left edges
leftedges=[0,10,20,30,40]
#Define the heights
heights=[500,800,645,700,900]
#Create a bar chart
plt.bar(leftedges, heights,5)
#Create X axis label
plt.xlabel('Year')
#Create Y axis label
plt.ylabel('Profit')
#Create X axis ticks
plt.xticks([0,10,20,30,40],
['2010','2011','2012','2013','2014'])
#Show the graph
plt.show()
#Call the function
main()
In the above code,
- • Define the function “main()”. Inside the function,
- ○ Create two lists to store the left edges and heights of all the bars.
- ○ Then create labels for the X and Y axes.
- ○ The function “xticks()” places the tick marks in the X axis at locations “0, 10, 20, 30,and 40” with the labels “2010, 2011, 2012, 2013, and 2014”, respectively.
Output:
Screenshot of the bar chart using the function “xticks()”
Function “yticks()”:
- • The function “yticks()” in Python enables the user to customize the tick marks labels along the Y axis.
- • This function sets the Y limits of the current location with the given tick label.
Syntax:
The “yticks()” function has the below format.
#Customize the tick marks along the Y axis
plt...
Want to see the full answer?
Check out a sample textbook solutionChapter 7 Solutions
Starting Out with Python (4th Edition)
- You need Create Transition table, Transition Graph, then bypass the graph to find the RE.?arrow_forward7- A student has created a plot of y(t)=t^2. He needs to show another graph of z(t)=t^3 in the same plot. But every time he hits the plot() function- MATLAB generates a plot of z(t) vs t but on a different window. What is the error? O It is not possible to plot multiple plots O He is not using the line function Maybe he is using polar() instead of plot() O He is not using the hold functionarrow_forwardComputer Graphicsarrow_forward
- What is the maximum number of colors the edges of a planar graph can be colored with? Four?arrow_forwardVolume of Histogram: Imagine a histogram (bar graph). Design an algorithm to compute the volume of water it could hold if someone poured water across the top. You can assume that each histogram bar has width 1. EXAMPLE Input: {0, 0, 4, 0, 0, 6, 0, 0, 3, 0, 5, 0, 1, 0, 0, 0} (Black bars are the histogram. Gray is water.) Output: 26 0 0 4 0 0 6 0 0 3 0 5 0 1 0 0 0arrow_forwardvBrian is a great mathematician. He recently managed to enter in world’s top 10 mathematician. His parents wanted to appreciate him and present him a Directed Acyclic Graph. He'd like to customize his graph. He wanted to add as many edges as possible in order to still have a DAG. Please, help Brian to write a python code, to find the maximum number of edges he can add to his graph without obtaining any cycle.Test your code on the following test case:3010000100Output:40 42 4arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education