UP | HOME

Exercise 19 solutions

Table of Contents


Python

e19.py

# ipython --pylab

# part 1
x = linspace(0.0, 0.9, 10)
y = sin(2*pi*x)
plot(x, y, 'k-')
xlabel('x')
ylabel('y')

# part 2
x = linspace(0.0, 0.9, 100)
y = sin(2*pi*x)
clf()
plot(x, y, 'k-')
xlabel('x')
ylabel('y')

# part 3
clf()
plot(x, y, 'b-', linewidth=5)
xlabel('x')
ylabel('y')

MATLAB / Octave

e19.m

% part 1
x = linspace(0.0, 0.9, 10)
y = sin(2*pi*x)
plot(x, y, 'k-')
box off
xlabel('x')
ylabel('y')

% part 2
x = linspace(0.0, 0.9, 100)
y = sin(2*pi*x)
plot(x, y, 'k-')
box off
xlabel('x')
ylabel('y')

% part 3
plot(x, y, 'b-', 'linewidth', 5)
box off
xlabel('x')
ylabel('y')

R

e19.R

# part 1
x = seq(0.0, 0.9, 0.1)
y = sin(2*pi*x)
plot(x, y, type="l", bty="l") # bty for no box

# part 2
x = seq(0.0, 0.0, 0.01)
y = sin(2*pi*x)
plot(x, y, type="l", bty="l")

# part 3
plot(x, y, type="l", bty="l", col="blue", lwd=10)

Paul Gribble | fall 2014
This work is licensed under a Creative Commons Attribution 4.0 International License
Creative Commons License