File:Sine quads 01 Pengo.svg

Original file (SVG file, nominally 1,065 × 459 pixels, file size: 59 KB)

Description Quadrants for sin(x)
Date
Source Own work
Author Pengo
SVG development
InfoField
 
The SVG code is valid.
 
This plot was created with Matplotlib.
Source code
InfoField

Python code

import numpy as np import matplotlib.pyplot as plt from math import pi import math  # HACKISH WARNING: this version internally uses 0 to 2 for the sine wave x axis, but labels it 0 to 2pi # This is so the two graphs can be the same size. I couldn't work out how to otherwise within pyplot. # (Actually only wanted the height of the two graphs to be the same, and was originally aiming to have the second x axis with the same scale as the first, which would have made it 3.14x longer.)  def addLines(quad, color): 	incr = 1.0/1000.0 	start = quad/2.0 	end = start + 0.5 + incr 	x = np.arange(start, end, incr) 	lines = plt.plot(x, np.sin(pi*x), '') 	plt.setp(lines, color=color, linewidth=2.5, solid_capstyle='butt', solid_joinstyle='miter')   def addPolar(quad, color): 	incr = pi/1000.0 	start = quad*pi/2.0 	end = start + pi/2.0 + incr 	x = np.arange(start, end, incr) 	lines = plt.plot(np.cos(x), np.sin(x), '') 	plt.setp(lines, color=color, linewidth=2.0, solid_capstyle='butt', solid_joinstyle='miter') 		 def addTicks(): 	start = 0 # in pi 	end = 3 # in pi 	tickPoints = [] 	tickNames = [] 	done = [] # in units of pi 	#denoms = [1, 2, 4, 8] # show more 	denoms = [1, 2] 	for denom in denoms: 		for numer in range(denom * start, denom * end): 			val = (numer+0.0)/(denom+0.0) 			if val not in done: 				#tickPoints.append(val * pi) # this is preferred 				tickPoints.append(val) # dodgy hack to help make the graph square.  				done.append(val) 				 				pich = u'\u03C0' 				strTop = str(numer) + pich 				if numer == 0: 					strTop = "0" 				elif numer == 1: 					strTop = pich 				  				if denom == 1: 					tickNames.append(strTop) 				else: 					tickNames.append(strTop + "/" + str(denom)) 	 	plt.xticks(tickPoints, tickNames)	  	 def drawSine(): 	addLines(-1, 'yellow') 	addLines(0, 'brown') 	addLines(1, 'r') 	addLines(2, 'orange') 	addLines(3, 'yellow') 	addLines(4, 'brown')  	addTicks() 	slack = .1 	plt.axis('scaled') 	plt.xlim(-slack, 2.0 + slack) 	plt.ylim(-1.1, 1.1) 	plt.grid(True) 	 	plt.xlabel('$x$') 	plt.ylabel('$y$') 	plt.title(r'$y = \sin x$')  	plt.text( .25,  0, 'I', family='serif', fontsize=26, ha='center', va='center') 	plt.text(.75,  0, 'II', family='serif', fontsize=26, ha='center', va='center') 	plt.text(1.25, 0, 'III', family='serif', fontsize=26, ha='center', va='center') 	plt.text( 1.75, 0, 'IV', family='serif', fontsize=26, ha='center', va='center')  def drawUnitCircle(): 	addPolar(0, 'brown') 	addPolar(1, 'r') 	addPolar(2, 'orange') 	addPolar(3, 'yellow')  	edge = 1.1 	plt.axis('scaled') 	plt.axis([-edge, edge, -edge, edge]) 	plt.grid(True)  	plt.xlabel('$x$') 	plt.ylabel('$y$') 	plt.title(r'$x^2 + y^2 = 1$') 	 	lo = .85 #label offset 	plt.text( lo,  lo, 'I', family='serif', fontsize=26, ha='center', va='center') 	plt.text(-lo,  lo, 'II', family='serif', fontsize=26, ha='center', va='center') 	plt.text(-lo, -lo, 'III', family='serif', fontsize=26, ha='center', va='center') 	plt.text( lo, -lo, 'IV', family='serif', fontsize=26, ha='center', va='center')  def twoInOne():	 	plt.subplot(121) 	drawUnitCircle() 	plt.subplot(122) 	drawSine()  twoInOne() plt.savefig("Sine_quads_01_Pengo.svg")  plt.show() 

Licensing

Image credit: Peter Halasz. (User:Pengo)

I, the copyright holder of this work, hereby publish it under the following license:
w:en:Creative Commons
attribution share alike
This file is licensed under the Creative Commons Attribution-Share Alike 3.0 Unported license.
You are free:
  • to share – to copy, distribute and transmit the work
  • to remix – to adapt the work
Under the following conditions:
  • attribution – You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
  • share alike – If you remix, transform, or build upon the material, you must distribute your contributions under the same or compatible license as the original.

When employing the Creative Commons license, give attribution to:

Although not a requirement of the license, if you use this image in print or media other than the web, I would appreciate it if you let me know. Please contact me if you require alternate licensing.

Captions

Add a one-line explanation of what this file represents

Items portrayed in this file

depicts

20 September 2010

60,692 byte

459 pixel

1,065 pixel

image/svg+xml

a0c36764fd723a21716b69115be2cafacd783b8b

File history

Click on a date/time to view the file as it appeared at that time.

Date/TimeThumbnailDimensionsUserComment
current01:55, 21 September 2010Thumbnail for version as of 01:55, 21 September 20101,065 × 459 (59 KB)Pengoadd quadrant labels
01:17, 21 September 2010Thumbnail for version as of 01:17, 21 September 2010963 × 441 (56 KB)PengoAdded axis labels and titles
03:16, 20 September 2010Thumbnail for version as of 03:16, 20 September 2010905 × 366 (42 KB)Pengo{{Information |Description=Quadrants for sin(x) |Source={{own}} |Date=2010-09-20 |Author= Pengo |Permission=see below |other_versions= }} Category:Sine function

The following page uses this file:

Global file usage