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)
- vBrian 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_forwardYou sketch a 3D graph of the function f(x,y,z)=z in pythonarrow_forwardMoon effect. Some people believe that the Moon controls their activities. If the Moon moves from being directly on the opposite side of Earth from you to being directly overhead, by what percentage does (a) the Moon's gravitational pull on you increase and (b) your weight (as measured on a scale) decrease? Assume that the Earth-Moon (center-to-center) distance is 3.82 x 10° m, Earth's radius is 6.37 x 106 m, Moon's mass is 7.36 x 1022 kg, and Earth's mass is 5.98 x 1024 kg. (a) Number 6.89 Units percent (b) Number i 6.8713e-4 Units percentarrow_forward
- Using the Matlab computer software, write the code to represent the following surface (put the title, axes and legend of the surface in the obtained graph) x2 = 4y2 + z2 (You can use a set of values between -5 to 5).arrow_forwardcomputer graphics search about simple utility curve link: https://www.codeproject.com/Articles/5267642/A-Simple-Utility-for-Drawing-Function-Curvesarrow_forwardAnswer question using imagearrow_forward
- Draw graph models, stating the type of graph used, to represent airline routes where every day there are four flights from Boston to Newark, two flights from Newark to Boston, three flights from Newark to Miami, two flights from Miami to Newark, one flight from Newark to Detroit, two flights from Detroit to Newark, three flights from Newark to Washington, two flights from Washington to Newark, and one flight from Washington to Miami, with a) an edge between vertices representing cities for each flight that operates between them (in either direction), plus a loop for a special sightseeing trip that takes off and lands in Miami 4. b) an edge for each flight from a vertex representing a city where the flight begins to the vertex representing the city where the flight endsarrow_forwardApply Bresenham’s Line Drawing algorithm to find the points of the line between the end points, (2,5) and (9,12)arrow_forwardHow will you represent a curve in graphics?arrow_forward
- Suppose that you are given an n × n checkerboard and a checker. You must move the checker from the bottom edge of the board to the top edge of the board according to the following rule. At each step you may move the checker to one of three squares: 1. the square immediately above 2. the square that is one up and one to the left (but only if the checker if not already in the leftmost column) 3. the square that is one up and one to the right (but only if the checker is not already in the rightmost column). 1 Each time you move from square x to square y, you receive p(x, y) dollars. You are given p(x, y) for all pairs (x, y) for which a move from x to y is legal. Do not assume that p(x, y) is positive. design a recursive backtracking algorithm that determines the maximum amount of money you can recieve, when moving a checker frmo somewhere on the bottom row to somewhere on the top row. your algorithm is free to pick any squrre along the bottom row as a starting point and any square along…arrow_forwardUsing Matlab computer software, write the code to represent the next surface given by the following equation (put the title, axes and legend of the surface on the obtained graph) x² + y2 – 2x – 6y – z + 10 = 0 (You can use a set of values between -5 to 5).arrow_forwardin openglarrow_forward
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781305480537Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT