using python
Type:
pip3 install matplotlib
This installs the matplotlib and you should be able to run the
code listed below in line_graph_example.py. The original x_coords
list had n+1 entries where n = 4. Make a new x_coords list have 2*n
+1 elements [0, 1, ..., 2*n] and augment the y_coords by adding
(using insert) a new value between any two old elements. The new
value should be the (average of neighbors +1). Then plot the new
data.
Line graph example code:
# This program displays a simple line graph. import matplotlib.pyplot as plt # Create lists with the X and Y coordinates of each data point. x_coords = [0, 1, 2, 3, 4] y_coords = [0, 3, 1, 5, 2] # Build the line graph. plt.plot(x_coords, y_coords) # Display the line graph. plt.show()
CODE:
import matplotlib.pyplot as plt
# Create lists with the X and Y coordinates of each data point.
# length of list
n = 4
# using range to populate a list from 0 to 2n
x_coords = list(range(0, 2 * n + 1))
# given y co-ordinates
y_coords = [0, 3, 1, 5, 2]
# to insert average of 2 old number in the between the numbers
for i in range(0, len(y_coords)+2, 2):
# calculate average
avg = (y_coords[i] + y_coords[i + 1]) / 2
# insert average at index i+1 which is in between 2 old numbers
y_coords.insert(i + 1, avg)
print(y_coords)
# Build the line graph.
plt.plot(x_coords, y_coords)
# Display the line graph.
plt.show()

OUTPUT:

Proof of work:
y_coords before execution: [0, 3, 1, 5, 2]
y_coords after execution: [0, 1.5, 3, 2.0, 1, 3.0, 5, 3.5, 2]
Please upvote if you like my answer and comment below if you have any queries.
using python Type: pip3 install matplotlib This installs the matplotlib and you should be able to...
This is a python matplotlib question. So it would be
great if you could show me in python method.
I have this loadtxt that asked to plot histogram of
wind gusts(column 3) that lie in direction angle(column 2) from min
angle to max angle inclusively. I don't know how to include
min_angle and max_angle into my codes.
Histogram of wind gust speeds As before the file akaroawindgusts.txt contains hourly maximum wind gusts speeds at the Akaroa Electronic weather station (EW)...
Python Programming language. Complete the problems below using Jupyter Notebook. Problem Needs to be solved from number #1 link provided for the Data: -----> https://docs.google.com/spreadsheets/d/1TqhyxFKQlOHAyXpQBL-4C96kgZFBoMwUgE8-b33CqPQ/edit?usp=sharing PROBLEMS # 0.0 Import the libraries (pandas, matplotlib, and seaborn) Include the code line: %matplotlib inline #Include the code line: plt.style.use(“ggplot”) #Load the data using pandas #Inspect the data using head(), dtypes ANSWERD: import pandas as pd import matplotlib.pyplot as plt import seaborn as sns plt.style.use('ggplot') %matplotlib inline df = pd.read_csv() print(df.head()) print(df.dtypes) # 1...
python / visual studio
Problem 1: Random Walk A random walk is a stochastic process. A stochastic process is a series of values that are not determined functionally, but probabilistically. The random walk is supposed to describe an inebriated person who, starting from the bar, intends to walk home, but because of intoxication instead randomly takes single steps either forward or backward, left or right. The person has no memory of any steps taken, so theoretically, the person shouldn't move...
Python, given a code in class i just need help with the third
bullet point ; using a and n (defined in the second picture of
python code) find the first digit for k! for k =1,...,n. you dont
have to type in all this code just help me write the code in the
first picture where it says: def benford(a):
b = [0 for d in range(1,10)]
#Do everthything in here
return b
2.2 Generating data In this assignment...
python
1
import matplotlib.pyplot as plt
2
import numpy as np
3
4
abscissa = np.arange(20)
5
plt.gca().set_prop_cycle(
’
color
’
, [
’
red
’
,
’
green
’
,
’
blue
’
,
’
black
’
])
6
7
class MyLine:
8
9
def __init__(self,
*
args,
**
options):
10
#TO DO: IMPLEMENT FUNCTION
11
pass
12
13
def draw(self):
14
plt.plot(abscissa,self.line(abscissa))
15
16
def get_line(self):
17
return "y = {0:.2f}x + {1:.2f}".format(self.slope,
self.intercept)
18
19
def __str__(self):...
python / visual studio
Problem 1: Random Walk A random walk is a stochastic process. A stochastic process is a series of values that are not determined functionally, but probabilistically. The random walk is supposed to describe an inebriated person who, starting from the bar, intends to walk home, but because of intoxication instead randomly takes single steps either forward or backward, left or right. The person has no memory of any steps taken, so theoretically, the person shouldn't move...
C# code Arrays and Linked Lists: Write C++/Java/C#/Python code to declare an array of linked lists of any primitive type you want. (Array of size 2020) (This could be based on MSDN libraries or the lab) – you do not need to instantiate any of the linked lists to contain any actual values. Paste your code for that here (this should only be one line) Based on your code or the lab from 4 or your doubly linked list from...
Design a program using Python and using from flask Import flask that generates a lottery number but in a website.. The program should have an Integer array with 9 elements. Write a loop that steps through the array, randomly generating a number in the range of 0 through 42 for each element. (Use the random function) Then write another loop that displays the contents of the array. Each number should be displayed as a list, the numbers should be generated...
Python code
You will need to make use of the random library for this homework. It is pretty simple to use. You can use the following methods: random.choice(list) returns a single item from the list, tuple or string at random. random.sample(list.o - returns a new list of n items randomly chosen from the list, tuple or string random shufflellist)randomly reorders all of the items in the list and changes the list itself. The list must be a mutable object so...
#PYTHON#
In this exercise you will write code which loads a collection of
images (which are all the same size), computes a pixelwise average
of the images, and displays the resulting average.
The images below give some examples that were generated by
averaging "100 unique commemorative photographs culled from the
internet" by Jason Salavon. Your program will do something
similar.
Write a function in the cell below that loads in one of the sets
of images and computes their average....