Last updated at 8:36 pm UTC on 23 May 2017
Author: Diego Gomez Deck
Morph to draw XY plots. See the methods testXXX in the class side.
- It is reachable with Package Loader as "Plot Morph" package (this is the best way how to install it).
- or you can download and install it on your own (if there is no Plot Morph package for your Squeak image version):
- Unless you change your color depth from 16 to 32, you might experience some troubles concerning the improper color rendering. This is nothing harmfull but may confuse you so you better change it to 32. (world menu / appearance ... / set display depth ... / 32)
See it in action
- Logarithmic and Exponential representation (eam)
- Try to evaluate the following commands in Workspace
- PlotMorph test
- PlotMorph test2
- PlotMorph test4
- Look at the code behind those methods in Browser
Question Kwiyi Woo February 01, 2004: I am pretty new to squeak and tried to use plotMorph to create a curve graph. I cannot find the methods "test", "test2" or "testWithReferences" in the PlotMorph class. How can the PlotMorph send message to them. Also I don't know how to plot a curve at specified function. Could anyone give me some suggestions?
Answer Germán S. Arduino: Look at class side for these methods. What I have found (in the test4) is this:
function := [:x | x degreesToRadians sin / 5 +
((x / 10) degreesToRadians cos +
(x / 10) degreesToRadians sin) 100].
do: [:x | pm series: #test2 addPoint: x
@ (function value: x)].
pm openInWorld 3
where a mathematical function is defined within a bloc “[ :x | x blabla....]” and assigned to the variable “function” to be used in the loop below where the “y” value of a point is compute with that “function” . So, if you change the mathematical function in that bloc you’ll have the result you are looking for.
Kwiyi Woo: I got the idea and successfully created my own graph. Thanks. But now I am trying to remove the grid on the Axis coordinators. In othe words, I only want to keep the X and Y axis without having a grid on the background. Is there any attribute I can turn off?
Raymond Asselin: As you see in a SystemBrowser, 5 classes are used to make aPlotMorph: AxesMorph, PlotMorph, PlotMorphGrid, PlotPoint and PlotSeries. So if you want to get rid of PlotMorphGrid you have to find where this class is used.
One way to find this is: (1) to select the PlotMorphGrid class in the SystemBrowser and (2) to choose in the contextual menu (alt+click on a Mac // right button on Windows) the menu item “class refs” this will open a window with the őusers1 of the selected class. You’ll see that there is only one user, it is the class AxesMorph in is őinitialize1 method. (3) Select it and you will see in the bottom pane the code. Find in which statement PlotMorphGrid is used. “grid := PlotMorphGrid on: self.”
I tried “grid := self. and the result seem to be what you are looking for.
So remember to look for the “class refs” of a class when you want to know “who uses it”, or “how” it is used.