Altair Compose® Challenge #1: Plotting in Compose with different types of axes
The main scripting language in Compose, OML, features a rich set of plotting commands for creating 2D and 3D plots. In this challenge we will explore some of them as well some nice features for arranging your plots.
When I was new to engineering scripting languages (Compose, Octave, MATLAB, etc.), I often was able to perform all the calculations I had to but had trouble in the last step of the process, I got stuck in displaying the results in a meaningful way. After going over this challenge, you will be ready to plot your data in different ways the next time you have to.
Download the attached script and follow the comments in there to create all plots. As you will see from the script, all plotting tasks should be done using this data:
x = 1:100;
y = x.^2;
z = x' * y / 2;
theta = 0:0.01:2*pi;
rho = cos(theta + 2*theta).*cos(theta);
The challenge is for you to display these vectors in the following types of plots:
- Conventional linear axes plot
- Scatter plot
- Logarithmic axes plots
- 3D line and surface plots
- Polar plot
After plotting in individual figures, create two new figures, one which contains all plots with logarithmic axes and another one containing all 3D plots, however you want to arrange them.
Good luck!
Tip: Check out OML functions like figure, grid, plot, scatter, semilogx, semilogy, loglog, plot3, surf, polar and subplot.
Level: Easy
Product Required: Compose 2020 or later version (including Personal Edition)
The solution can be attached in the comment section of this post. The desired output format is a zip file containing the plots created as JPG images. These images can be saved directly from Compose or they can be screenshots.
Edit: The solution to this challenge has been attached as another OML script. Try to solve it on your own before looking at it!
Find more posts tagged with
Comments
I can't upload the file due to company's policy. so I write the code below instead.
plot(x,y);
scatter(x,y);
semilogx(x,y);
semilogy(x,y);
loglog(x,y);
plot3(x,y,z(:,1,1));
surf(x,y,z);
polar(theta, rho);
subplot(3,1,1);
semilogx(x,y);
subplot(3,1,2);
semilogy(x,y);
subplot(3,1,3);
loglog(x,y);
subplot(2,1,1);
plot3(x,y,z(:,1,1));
subplot(2,1,2);
surf(x,y,z);
I can't upload the file due to company's policy. so I write the code below instead.
plot(x,y);
scatter(x,y);
semilogx(x,y);
semilogy(x,y);
loglog(x,y);
plot3(x,y,z(:,1,1));
surf(x,y,z);
polar(theta, rho);subplot(3,1,1);
semilogx(x,y);
subplot(3,1,2);
semilogy(x,y);
subplot(3,1,3);
loglog(x,y);subplot(2,1,1);
plot3(x,y,z(:,1,1));
subplot(2,1,2);
surf(x,y,z);
hi Soodong. Plot commands look good but each one should be created in a new figure. Also, remember to set a grid for each plot.
Files attached. It's an interesting exercise!
Thanks.
Xiaolei