ASKSAGE: Sage Q&A Forum - Latest question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Mon, 13 May 2019 14:52:54 -0500How to combine 3d and 2d plots?http://ask.sagemath.org/question/46508/how-to-combine-3d-and-2d-plots/ Hi, I am trying to include 2d plots of a 3d functions in specific points, fx. if i have a plottet function z=y*z and then i want to plot a function over when y=1 or 2 or 3 and so on. or when x=1 or 2 or 3 and so on.
I am dealing with this assignment:
sage: x,y,z = var('x,y,z')
sage: f = x^2+sqrt(y)
Then i can prepare that one for a 3d plot
sage: P = f.plot3d((x,-5,5),(y,-5,5),color="red",opacity=0.7)
Then i read something somewhere that you can put the cuts in the 3dplot by
sage: plot3d(z=0, **kwds)
and they gave the EXAMPLE:
sage: sum([plot(z*sin(x), 0, 10).plot3d(z) for z in range(6)]) #long
So for my case i try
sage: S = sum([plot(x^2+sqrt(y), -5,5 for y in range(6)])
sage: K = P+S
sage: K.show(aspect_ratio=[1,1,1])
Because i don't know how to include the z axis in the example. So i get some lines but they are lying down on the x/y axis i tried changing the variable y with z but it doesnt change anything.
Please help me!
Kind regards
Martin MÃ¥rtenssonMartin MÃ¥rtenssonMon, 13 May 2019 14:52:54 -0500http://ask.sagemath.org/question/46508/Vector field: how to make arrows fine? (plot2d)http://ask.sagemath.org/question/44705/vector-field-how-to-make-arrows-fine-plot2d/I'm using the function arrow and I'm trying to have arrows fine like the one you can find on the wikipedia page of vector field, because the normal arrows in Sage are not enough fine for me. I looked at the manual and at the properties of arrows but I found nothing.
Thank you for any help :)
here is my code:
def champs_vecteur(f,L,n):
P = point((0,0))
for k in [-n..n]:
for l in [-n..n]:
i = L*k
j = L*l
(u,v) = f(i,j)
nor = sqrt(u*u+v*v)/L
if nor != 0:
u = u/nor
v = v/nor
P += arrow( (i-u/2,j-v/2) , (i+u/2,j+v/2) ,color="black", arrowsize=3,width=1)
show(P,aspect_ratio=1)
I use it like that
var('y')
h(x,y) = (-x-y,-y+x)
champs_vecteur(h,0.1,10)JawakaTue, 18 Dec 2018 05:45:20 -0600http://ask.sagemath.org/question/44705/How to change linestyle of 2d vector field plotshttp://ask.sagemath.org/question/10956/how-to-change-linestyle-of-2d-vector-field-plots/How can I change the linewidth and the arrow tips of a 2d vector field plot?sagefanThu, 23 Jan 2014 07:41:24 -0600http://ask.sagemath.org/question/10956/Documentation for show involving ymin and ymaxhttp://ask.sagemath.org/question/10733/documentation-for-show-involving-ymin-and-ymax/I was reading the documentation on 2d plotting again and I noticed something that I find strange. In the [plot documentation](http://www.sagemath.org/doc/reference/plotting/sage/plot/plot.html#sage.plot.plot.plot), there is the following phrase:
>If you want to limit the plot along the horizontal axis in the final rendered figure, then pass the xmin and xmax keywords to the show() method. To limit the plot along the vertical axis, ymin and ymax keywords can be provided to either this plot command or to the show command.
Ok, so this feels pretty obvious and all is well and good. But then you get [other questions](http://ask.sagemath.org/question/1242/add-plots-with-different-ymin-ymax-parameters) that show that ymin and ymax don't behave naively, nor are they associated directly with plot. Instead, that [answer](http://ask.sagemath.org/question/1242/add-plots-with-different-ymin-ymax-parameters?answer=1957#1957) says that ymin and ymax are really just always passed to show, and so should be thought of as show arguments.
Hmm, so it's not so obvious. So we might go to the [show documentation](http://www.sagemath.org/doc/reference/plotting/sage/plot/graphics.html#sage.plot.graphics.Graphics.show) to better understand what is going on. Unfortunately, show does not mention anything about ymin or ymax, or what happens when they're added together.
As far as I can tell, there is nothing in any show documentation that mentions ymin or ymax. Is that correct? If so, is that by design?mixedmathWed, 13 Nov 2013 16:48:47 -0600http://ask.sagemath.org/question/10733/Plotting the effects of a linear transformation on a gridhttp://ask.sagemath.org/question/10691/plotting-the-effects-of-a-linear-transformation-on-a-grid/I am a student taking a first undergraduate course in linear algebra, and I would like to play around with plots of transformations of the type $T:\mathbb{R}^2\rightarrow\mathbb{R}^2$. I already know a bit of python, so I'm not looking for anyone to write a program for me, but I would really appreciate some tips/general outline of how to do things.
1) First I want to make a grid that I can plot, and then transform by multiplying it with a matrix. Where's the best way to start? Should I use parametric_plot, or maybe it can be done with just a list of **vector([x,y])**'s?
2) Second I want to run the grid through a linear transformation. If I could just plot vectors and offset them (not having them start at the origin), I would only only have to iterate over a list of vectors to get the transformed vectors, but I'm not sure if this is a smart way to do it.
Basically, is there a straight forward way to do this? It doesn't seem like it should be very difficult, if someone could give a rough outline of how to do this it would be greatly appreciated.
Thanks.
eodSun, 03 Nov 2013 02:13:24 -0600http://ask.sagemath.org/question/10691/2D stem plothttp://ask.sagemath.org/question/10164/2d-stem-plot/Hi, this is not really a question but I come by these days to search for a stem plot, can't find any useful and finally came up with the following solution, I want to share:
def stem(data,offset=0,**kwargs):
p=point([])
l=line([])
for d in range(len(data)):
p+=point((d+offset,data[d]),size=50)
l+=line([(d+offset,0),(d+offset,data[d])])
show(p+l,xmax=len(data),**kwargs)
for example:
values=[]
for v in range(0,5):
values.append(1/4^v)
stem(values,ymax=1,axes_labels=('n','x[n]'))
#or with offset
stem(values,-4,ymax=1,axes_labels=('n','x[n]'))
- arg1 list of data
- arg2 gives you the opportunity to adjust the starting point
- **kwargs passes all following arguments to the show-functionfarnzworldWed, 29 May 2013 07:57:50 -0500http://ask.sagemath.org/question/10164/Empirical Data Plothttp://ask.sagemath.org/question/9914/empirical-data-plot/I wish to make a plot of N vs Time where $N=$ # of edges in a graph.
i.e. i want to make an empirical estimate of the time complexity it takes to compute certain things about a graph based on its number of edges.
so i guess i'm wanting to know how i can plot these data points in sage and find a polynomial that best fits?
i.e.
N = [(16,28,59,120)]
T = [(0.135,0.523,7.36,248)] --where time is measured in seconds
i'm a beginner so any help will be much appreciated.jtaaFri, 15 Mar 2013 02:07:41 -0500http://ask.sagemath.org/question/9914/How would you plot these data points?http://ask.sagemath.org/question/9867/how-would-you-plot-these-data-points/(x=nodes, y=cycles)
the following 3 sets of data points on the same graph:
IZF (color=red): [(0,0),(1,0),(2,0),(3,35),(4,105),(5,252),(6,1260),(7,2910)]
vs
Actual (color=black): [(0,0),(1,0),(2,0),(3,35),(4,105),(5,252),(6,420),(7,360)]
vs
c_adj (color=blue): [(0,0),(1,0),(2,42),(3,210),(4,1302),(5,7770),(6,46662),(7,279930)]
i'm not even sure what type graph would be appropriate, whereby you can see reasonably where each point y is, because my current plots (due to y going up to 279,930) shows the different data points coinciding, i.e. you cant differentiate between the initial datapoints.
jtaaFri, 01 Mar 2013 07:26:57 -0600http://ask.sagemath.org/question/9867/Plotting points with different colourshttp://ask.sagemath.org/question/9701/plotting-points-with-different-colours/I'm trying to plot a number of points such that each has a colour that depends on a certain parameter. I have two lists, `points` and `heights`, and I would like to do something like this:
for i in range(len(points)):
point2d(points[i], rgbcolor = (0,0, heights[i]))
This creates `len(points)` different graphics, so it's not what I want. What do I need to change?manolomartinezFri, 11 Jan 2013 03:58:31 -0600http://ask.sagemath.org/question/9701/2d plot axes labelshttp://ask.sagemath.org/question/9235/2d-plot-axes-labels/Hello,
How do I add labels (names) to my axes when doing a simple 2d plot such as:
t = var('t')
E(t)=(10.40*(1-exp(-0.25*t)))^2.81
plot(E,t,(x,0,15))
I would like to do so the labels are aligned directly under the x axis and vertically over the y axis. Is there a way?brenogilTue, 14 Aug 2012 08:20:31 -0500http://ask.sagemath.org/question/9235/Is there a reasonable way to plot arcsec (real) without having a line connecting the branches?http://ask.sagemath.org/question/9104/is-there-a-reasonable-way-to-plot-arcsec-real-without-having-a-line-connecting-the-branches/I'm working on a student exploration of inverse trig functions (interact), and I'd like to plot y=arcsec(x), say from -8 to 8, without having to specify the domain. How do I turn off the spurious line that Sage draws?dasmith88Fri, 22 Jun 2012 06:40:52 -0500http://ask.sagemath.org/question/9104/