ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Thu, 04 Feb 2016 06:04:28 +0100How do you overlay trajectory graphs on vector fields?https://ask.sagemath.org/question/32439/how-do-you-overlay-trajectory-graphs-on-vector-fields/Hi, I'm doing a programming problem where I have to graph a vector field, then overlay trajectory graphs with different initial values on it.
So far this is what I have:
var('R, S')
plot_vector_field([3*R - R^2 - 2*R*S, 2*S - S^2 - R*S], (R,-50, 50), (S, -50, 50))
R = sol[:,0]
S = sol[:,1]
list_plot(zip(R,S), plotjoined=True)
The last line always produces a separate graph. I've tried using the "**+**" operator to "add" it to the vector field graph, but that gives me an error instead. I also don't know how to repeat the process (i.e. overlay additional trajectories) without having to make a new graph for each. Truth be told I'm only a beginning coder and have some trouble synthesizing different coding aspects together.
Any help would be greatly appreciated!
jeannedarcThu, 04 Feb 2016 06:04:28 +0100https://ask.sagemath.org/question/32439/Problem showing imageshttps://ask.sagemath.org/question/9254/problem-showing-images/I am quite new to SAGE so I am probably asking something silly but some days of google search did not provide a simple answer to my question.
Using instructions from [this](http://blancosilva.wordpress.com/2010/12/15/image-processing-with-numpy-scipy-and-matplotlibs-in-sage/) website I created a small sage program:
from numpy import *
import scipy.ndimage
import matplotlib.image
import matplotlib.pyplot
img=matplotlib.image.imread(DATA+'dummy.png')
print 'Image dtype: %s'%(img.dtype)
print 'Image size: %6d'%(img.size)
print 'Image shape: %3dx%3d'%(img.shape[0],img.shape[1])
print 'Max value %1.2f at pixel %6d'%(img.max(),img.argmax())
print 'Min value %1.2f at pixel %6d'%(img.min(),img.argmin())
print 'Variance: %1.5f\nStandard deviation: %1.5f'%(img.var(),img.std())
where dummy.png is an existing PNG image that I loaded into the worksheet.
The script works perfectly and I get the required info out of it:
Image dtype: float32
Image size: 17335905
Image shape: 2305x2507
Max value 1.00 at pixel 1767
Min value 0.00 at pixel 2032962
Variance: 0.06310
Standard deviation: 0.25120
now if I want to actually see the picture everything fails. I tried to type:
img
show(img)
img.show
img.show()
My final goal was to overlay the image, a photo, with the plot resulting from an analysis to show the accuracy of the prediction. Does anyone know how to do that?
thanks,
mcirrimcirriMon, 20 Aug 2012 11:27:05 +0200https://ask.sagemath.org/question/9254/