More ‘Spirograph (®) plots using ‘matplotlib’

‘Spirograph’ includes toothed rings which can be used with small disks to draw Spirograph patterns inside the ring. The small toothed rolls around the inside of the fixed ring, producing the typical Spirograph spirals.

The diagram above shows how this works. The small circle rolls around inside the larger circle (which represents the inside of the ring). If there is no slippage, the small circle rotates in the opposite direction to its movement around the larger circle.

I modified my Python program to simulate this situation. As before, the rate of rotation of the smaller circle can be controlled by varying the ‘mult2’ variable in the program. To start with I used a small value for the variable as shown below.

The diagram has five ‘lobes’ and an empty patch in the middle. The curve can never go through the centre. If the ratio of the sizes of the circles is less than one half, then smaller circle is not big enough to reach the centre of the larger circle. If the ratio of the sizes of the circles is greater than one half, then the point on the circumference of the smaller circle that is drawing the curve (point D on the diagram above) never falls on the centre of the larger circle. If the ratio of sizes is exactly one half, all the loops will pass through the centre of the larger circle.

As the multiplier ‘mult2’ is increased, the curve comes to resemble the circular shape of a typical Spirograph. I think that it looks a bit like a torus or a donut.

I’m not going to try to emulate the behaviour of the non-circular Spirograph components. In fact, I have only emulated the circular ones, but not completely. I’ve only plotted the curves that would result if the point P (the pen) corresponded to the point D (on the smaller circle) in the diagram above.

Here’s one final plot, where the ratio of the smaller circle to the larger circle is exactly one half. The program draws a pleasant chrysanthemum or dahlia shape.

Finally, here’s the Python program that I used to draw these diagrams. To get the different figures, I’ve changed the multipliers, mainly ‘mult2’. I’ve also changed the sizes of the circles (variables ‘large’ and ‘small’) to get some of them.


import numpy as np
import matplotlib.pyplot as plt

# Dimensions of two circles
r1 = 100
r2 = 50
# c0 = [0,0]
# c1 = [1,0]

# Multipliers
mult = 10   # Used to generate the number of points plotted.
mult2 = 25  # Controls speed of rotation of the smaller circle, relative to the first.

ax = plt.subplot()
ax.set_aspect( 1 )

# Parametric array for the larger circle
t1 = np.linspace(-2 * np.pi, 2 * np.pi, mult * 360)
# Parametric array for the smaller circle
t2 = t1 * mult2

# Calculation of X/y cordinates using the parametric arrays.
# x0 and y0 are the coordinates of the tangential point, B.
x0 = r1 * np.cos(t1)
y0 = r1 * np.sin(t1)
# plt.plot(x0, y0, label=("Large circle"), color = 'r', linewidth = 2, linestyle = '--')
# x1 and y1 are the cordinates of the centre of the small circle, C.
x1 = (r1 - r2) * np.cos(t1)
y1 = (r1 - r2) * np.sin(t1)
# x1a and y1a are the coordinates of D relative to C.
x1a = r2 * np.cos(t2)
y1a = r2 * np.sin(t2)
# plt.plot(x1a, y1a, label=("Small circle"), c = 'r', linewidth = 2, linestyle = '--')
# x2 and y2 are the coordinates of the desired point on the curve, D.
plt.plot(x0[0],y0[0], color='r')
# The small circle rolls in the opposite direction if it is inside
x2 = r2 * np.cos(-t2)
y2 = r2 * np.sin(-t2)

# Plot the Curve
# plt.plot(x1 - 1.5 * x2, y1 - 1.5 * y2)
plt.plot(x1 + x2, y1 + y2, label=("'Spirograph' curve"), c = 'b', linewidth = 1)

plt.title("Inside, mult = {}, mult2 = {} ".format(mult, mult2))
plt.legend(loc="upper right")
plt.show()

One Hundred and One

English: Wayne County (NY) Route 101 shield. P...
English: Wayne County (NY) Route 101 shield. Public domain. Unlike most counties, Wayne County posts its county routes on blade signage. (Photo credit: Wikipedia)

The last post that I made was my 100th post on this blog. I’ve tried to keep blogs before now, but I’ve always failed at some point. There are blogs started by me at various places on the Internet, but this is the only one to have got past a few dozen posts.

I’m not sure of the reason why I’ve been able to keep this blog going and I’ve failed before. I don’t think that it is the fact that this is a WordPress blog, as I’ve not found significant differences between the various type of blog. They all do pretty much the same thing.

English: WordPress Logo
English: WordPress Logo (Photo credit: Wikipedia)

Of course, there are myriads of themes out there, but it is impossible to hide the underlying structure completely – you create a blog post, you post it and people are able to look at it.


Embed from Getty Images

There are no doubt those who have specific needs and need specific features, for example if they are selling something and need to accept payments, who find that a specific blogging platform is required to fill their needs, but most people will find, I think, that the blogging platform that they use is mostly irrelevant.

I have committed myself to creating blog post of around 1,000 words once per week and so far I’ve been able to achieve this. I plan to have a post ready to go on Monday evening. Below I’m going to describe how I write a post. It’s a creative process, with a small ‘c’. It’s not Creative with a large ‘C’, a work of Art, as I don’t aspire to such exalted levels. It’s just my small blog.

Brain, computer art
Brain, computer art (Photo credit: Wikipedia)

When I sit down to write a post, I usually, but not always, have a topic in mind. If I am lucky I will have been thinking about it during the week and I have some idea on what I am going to include in the post. However, I don’t plan it out as such. I just some ideas, some pretty well developed in mind.

Sometimes though, I sit down at the computer with maybe only a topic or not even that. I type the title and I’m away! So far I’ve not had any real difficulty in reaching the 1,000 words, and sometimes I have to leave things out.

1000 Pennies for Your Thoughts - NARA - 534149
1000 Pennies for Your Thoughts – NARA – 534149 (Photo credit: Wikipedia)

It is usually reckoned that a work of this sort has a distinct beginning and end. I certainly open with a sentence on what I about to write about  and then go on to write about it, but I don’t try to tag on a definitive conclusion, especially if I am running on, and the word count gets significantly higher than 1,000 words.

So anyway, I start writing. As I write I might plan ahead a little, but more often than not I put down my current thought which might take a sentence or three and I correct and formulate my sentences as I go. I look back a little too, and may revise a sentence or phrase in the current paragraph if it strikes me as being too ugly.

English: New York, New York. Newsroom of the N...
English: New York, New York. Newsroom of the New York Times newspaper. Reporters and rewrite men writing stories, and waiting to be sent out. Rewrite man in background gets the story on the phone from reporter outside. (Photo credit: Wikipedia)

I don’t however have the whole thing in my mind, though I may remember and revisit thoughts that I have written earlier if something strikes me. I do think ahead a little, or maybe a paragraph or two, but in general, I compose as I write as I go.

Sometimes I pause, as I just did, to think my way ahead. This is an indication to me that I’ve said all that comes to mind on the point that I was making and that I should start another point.


Embed from Getty Images

I am not formal about references and in fact mostly use Wikipedia for any references, but I try to link to the work of others and sometimes to major references. If a reader has an interest in any of the topics that I touch on, Wikipedia, for all its faults, can be a good place to start.

The result, I suspect, is almost certainly more of a ramble through the topic in question than a serious analysis of it. Caveat Emptor! Of course, anything that I write is my opinion only.

English: Front of Caveat Emptor, a rare books ...
English: Front of Caveat Emptor, a rare books store located at 112 N. Walnut Street in downtown Bloomington, , . Built in 1900, it is part of the Courthouse Square Historic District, a historic district that is listed on the . (Photo credit: Wikipedia)

When I have finished writing the post, I save it, and then start “decorating” it. By this I mean that I insert images every paragraph or so, to break up the post into more readable chunks. A single mass of text is off-putting I find. That’s also why I kept the paragraphs short too.

I choose the picture purely on their look. I don’t check the websites that the image come from, so people should not assume that I in any way agree or disagree with the authors of the websites that I borrow images from.

Internet packet path
Internet packet path (Photo credit: Wikipedia)

This is probably not a big deal, as I usually use Zemanta to provide the images and they provide links mainly from Wikipedia. Also using a source like Zemanta means that there should be no copyright issues with the images that I include.

When I have finished writing the post and I have inserted my images, I categorise the post using my usual categories and include tags. Doing this is supposed to help people looking for posts on particular topics and tagging in particular should enable my posts to come up in searches. Apparently tagging posts helps search engines.


Embed from Getty Images

The way that I write posts mean that there is a danger that I might meander through a topic rather than do a tight analysis of it. That’s OK by me. However I don’t know if the readers of my posts consider them to be rambling or whether I unconsciously put in there a structure that I am unaware of when I write a post.

Essentially, though, I write for myself, to get my ideas out there, to amuse myself and to test myself. When I write, I am, in my own mind, in a way, writing to myself, as if I the reader were a different person to I the writer. I know the occasional real person stumbles on my writing, and if they get something out of it, I am glad. If they don’t get something out of it, well, that’s fine, but I guess that they won’t be back!

Wayne County (NY) Route 102 shield. Public dom...
Wayne County (NY) Route 102 shield. Public domain. Unlike most counties, Wayne County posts its county routes on blade signage. (Photo credit: Wikipedia)