# python graph
# i want to add a caption below this graph
import matplotlib.pyplot as plt
import numpy as np
import math
#pylab inline
from mpl_toolkits.mplot3d import Axes3D
a = np.linspace(50,200,50)
b = np.linspace(500,2000,50)
c = np.linspace(5,20,50)
plt.axes(projection='3d')
for i in c:
plt.plot(a,b,i)
plt.title("title)
plt.yaxis("y axis ")
txt = "this is a graph of a bunch of lines" #cant get this to
work
plt.text(0.5, 0.05,0.7,0.1, txt, ha='center') ##cant get this to
work
plt.set_size_inches(7, 8,6, forward=True) #cant get this to
work
plt.show()
import matplotlib.pyplot as plt
import numpy as np
import math
#pylab inline
from mpl_toolkits.mplot3d import Axes3D
a = np.linspace(50,200,50)
b = np.linspace(500,2000,50)
c = np.linspace(5,20,50)
plt.axes(projection='3d')
for i in c:
plt.plot(a,b,i)
plt.title("title)
plt.yaxis("y axis ")
txt = "this is a graph of a bunch of lines"
fig = plt.figure() #Intialize the figure
fig.text(.5, 0.05, txt, ha = 'center') # Add text to figure
plt.set_size_inches(7, 8, forward=True)
plt.show()
# python graph # i want to add a caption below this graph import matplotlib.pyplot as plt import ...
#python, printing alpha beta and theta symbols # i want to be able to put an alpha beta and theta symbol in this graph using python import numpy as np import matplotlib.pyplot as plt a = np.linspace(0,50,50) b=[] for i in a: b.append(np.sin(i)) plt.plot(a,b) #################################### #### problem is just below ##### #################################### plt.xlabel('$\Theta$ (lol)') plt.ylabel('$\Alpha$ (lol)') plt.title('$\Beta$ (lol)') plt.show()
IN PYTHON 3 GIVING THIS CODE %matplotlib inline import numpy as np import matplotlib.pyplot as plt from sklearn import datasets N_samples = 2000 X = np.array(datasets.make_circles(n_samples=N_samples, noise=0.05, factor=0.3)[0]) plt.scatter(X[:,0], X[:,1], alpha=0.8, s=64, edgecolors='white'); Use Spectral Clustering to cluster the points and visualize your result
Python import numpy as np import matplotlib.pyplot as plt Implement three different methods to simulate a Poisson process (No λ 0.1 on the time interval [0, 1001 with parameter For each method, plot a trajectory of your simulated process. 1. Method 1:use the exponentially distributed interarrial times
Python import numpy as np import matplotlib.pyplot as plt Implement three different methods to simulate a Poisson process (No λ 0.1 on the time interval [0, 1001 with parameter For each method, plot...
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, I need help with glob. I have a lot of data text files and want to order them. However glob makes it in the wrong order. Have: data00120.txt data00022.txt data00045.txt etc Want: data00000.txt data00001.txt data00002.txt etc Code piece: def last_9chars(x): return(x[-9:]) files = sorted(glob.glob('data*.txt'),key = last_9chars) whole code: import numpy as np import matplotlib.pyplot as plt import glob import sys import re from prettytable import PrettyTable def last_9chars(x): return(x[-9:]) files = sorted(glob.glob('data*.txt'),key = last_9chars) x = PrettyTable() x.field_names =...
PYTHON
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from sklearn.linear_model import LinearRegression
from sklearn.linear_model import LogisticRegression
from sklearn.model_selection import train_test_split
Our goal is to create a linear regression model to estimate
values of ln_price using ln_carat as the only feature. We will now
prepare the feature and label arrays.
"carat" "cut" "color"
"clarity" "depth" "table"
"price" "x" "y" "z"
"1" 0.23 "Ideal" "E" "SI2" 61.5 55 326
3.95 3.98 2.43
"2" 0.21 "Premium" "E" "SI1"...
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...
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)...
Hi. It's a python and I got an error below comment import numpy as np arr=np.genfromtxt("/Volumes/Samsung SSD 860 EVO 500GB Media/Download/primenumbers.txt", dtype=int) arr=arr.reshape(-1,1) arr.shape def find_cat(x): if x<= 300: return '<=300' elif x <= 600: return '<=600' else: return '<=1000' arr2 = np.apply_along_axis(find_cat, axis=1, arr=arr) arr2 = arr2.reshape(-1,1) arr3 = np.hstack((arr, arr2)) arr_300 = np.array((col[0] for col in arr3 if col[i]=='<=300'), dtype=int) arr_300 arr_300.shape count_300=len(arr_300) count_300 avg_300=round(np.mean(arr_300, 2) avg_300 print("Number of items in category \ "<=300\"= (one), and average of...
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...