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.Sat, 10 Oct 2020 15:20:18 +0200- Plotting in base n?https://ask.sagemath.org/question/53815/plotting-in-base-n/In sagemath is there a way to represent plots in bases other then base10? If at all possible being able to plot from base2 to base36.nooniensoong97Sat, 10 Oct 2020 15:20:18 +0200https://ask.sagemath.org/question/53815/
- Strategies for plotting graphs with many verticeshttps://ask.sagemath.org/question/53126/strategies-for-plotting-graphs-with-many-vertices/I've found that sage is good at drawing small graphs, but becomes decreasingly useful for visualizing your graph as the number of vertices increases. This is doubly true if you want to label your vertices. Oftentimes I feel like this is due to sage trying to keep the graph image somewhat small, and I would be happy to trade an image with large xy dimensions in exchange for more spread out vertices, which will give the labels room to be legible.
I know that sage will let you manually choose where the vertices go, but often I am drawing graphs to try to visualize things quickly to develop conjectures, and it is more important that I be able to go through lots of examples than it is to have each one perfect.
Does anyone know of a way to get sage to spread the vertices out more aggressively, and generally to get it to plot graphs with ~50 nodes while maintaining legibility? I'm aware there was a question about a similar topic here (apparently I don't have enough karma to post links: /question/9305/strategies-for-drawing-good-graphs-graph-theory/), but seeing as that was 8 years ago, it seems reasonable that there may have been some developments.
Thanks in advance ^_^ HallaSurvivorFri, 21 Aug 2020 00:45:51 +0200https://ask.sagemath.org/question/53126/
- How to get the points from a contour plot object?https://ask.sagemath.org/question/50024/how-to-get-the-points-from-a-contour-plot-object/I've defined a plot object for the hyperboloid in R^(-1,1).
hyperboloid = region_plot(-x^2+y^2 == 1, (x,-3,3),(y,-3,3))
I want to reflect this hyperboloid across a plane, and to do that I can't think of a better way than to somehow extract the points from the ContourPlot object behind the hyperboloid and then apply a reflection transformation to each point, then plot the points I get back. How do I get the points backing the plot? If that's not possible, or if there is a better way, how can I achieve my desired reflection?jaykruSat, 22 Feb 2020 20:28:36 +0100https://ask.sagemath.org/question/50024/
- Schwarz-Christoffel transformationshttps://ask.sagemath.org/question/48332/schwarz-christoffel-transformations/I would like to visualize the Schwarz-Christoffel transformations. Do you have an idea how to implement those? For example a polygon (as a domain) in the complex plane and subsequently also a map (decomposed into several steps) into the upper half-plane of the complex plane should be drawn. I am not quite sure how to do this. The formulas for these transformations are well-known.Tintin1Mon, 14 Oct 2019 15:27:31 +0200https://ask.sagemath.org/question/48332/
- plot comment not workinghttps://ask.sagemath.org/question/47358/plot-comment-not-working/![image description](/upfiles/15648319845492248.png)
Why the image of the graph is not displayed here? Kindly help me with resolving this.
I am using Mac.
Thank you.GA316Sat, 03 Aug 2019 13:34:18 +0200https://ask.sagemath.org/question/47358/
- How do i change the x and y steps of an plot?https://ask.sagemath.org/question/44237/how-do-i-change-the-x-and-y-steps-of-an-plot/So i want a coordinate system that has different steps for example.
i have this
plot(-1/2*x+1,(x,-2, 8), rgbcolor=('#00c147')) #h1
how can i change the steps at the x-axis, at the moment it prints the numbers at {-2,2,4,6,8}
and i want it to be {-2,-1,0,1,2,3,4,5,6,7,8}
how can i customize those steps at the x and y-axis and how can i make it printable that for example 1 step has the distance of 0.5cm+0.5cm on a plain A4 paper.
at the moment 1 is at 1.5cm, 2 at 3cm EDIT:(nvm the printer had the wrong settings)neorySun, 11 Nov 2018 15:03:26 +0100https://ask.sagemath.org/question/44237/
- creating graph with dotted edgeshttps://ask.sagemath.org/question/43872/creating-graph-with-dotted-edges/ Hello all,
I need to draw a graph in which some edges are usual and some edges are dotted. I know how to make all the edges dotted (using the option "dotted" for the parameter edge_style of plot). But I need mixed edges (some are dotted and some are usual). Kindly help me with this.
Thank you.
GA316Mon, 08 Oct 2018 18:17:43 +0200https://ask.sagemath.org/question/43872/
- plotting autonomous differential equationshttps://ask.sagemath.org/question/43748/plotting-autonomous-differential-equations/I'm trying to plot the slope field and some solutions to
$$\frac{dx}{dt}=x^2-4x$$
I was able to get the slope field to plot with:
x,y=var('x','t')
plot_slope_field(x^2-4*x,(t,0,5),(x,-4,8))
I can't figure out how to the solutions to plot. I can get a general solution:
t = var('t')
x = function('x')(t)
f=desolve(diff(x,t) == x^2-4*x,[x,t])
show(f)
$$\newcommand{\Bold}[1]{\mathbf{#1}}\frac{1}{4} \, \log\left(x\left(t\right) - 4\right) - \frac{1}{4} \, \log\left(x\left(t\right)\right) = C + t$$
If I try it with initial values, say ics=[2,2], I get imaginary solutions:
$$\newcommand{\Bold}[1]{\mathbf{#1}}\frac{1}{4} \, \log\left(x\left(t\right) - 4\right) - \frac{1}{4} \, \log\left(x\left(t\right)\right) = \frac{1}{4} i \, \pi + t - 2$$
I was able to plot solutions with another windows tool, winplot, but really want to do it in sage. Any clues on how I can do that?AndyHTue, 25 Sep 2018 09:00:20 +0200https://ask.sagemath.org/question/43748/
- Using Sage plotting capability on data from PARI/GPhttps://ask.sagemath.org/question/41029/using-sage-plotting-capability-on-data-from-parigp/I am trying to plot data in Sage that is generated by a function in PARI/GP, however keep getting type errors.
I use this simple example to illustrate the point:
f=(gp("Z(s)=zeta(s)"))
f(2)
This gives the correct output 1.6449340668482264364724151666460251892 and appears to be a 'normal' floating point number that I can indeed multiply/add with.
However, when I try the following:
plot(f,(2,6))
It keeps coming back with
TypeError: Error executing code in GP
I have studied most of the (limited) info on the Pari/GP interface and did read that PARI/GP always returns a string. I therefore tried to convert the returned value into a float, int etc., however nothing works. I very likely do something wrong (or not allowed) and would be grateful for any advice on what could be the issue here (esp. since f(2) gives the correct numerical floating point result).
Thanks!
RuudHThu, 08 Feb 2018 12:49:41 +0100https://ask.sagemath.org/question/41029/
- How do we graph sequenceshttps://ask.sagemath.org/question/38506/how-do-we-graph-sequences/ For example
def agen(max=Infinity):
n = 1
an = 1
while n <= max:
yield an
n += 1
an = (an + 1)/an^2
a = agen(10)
for i in a:
print i.n()
The above print the sequence, but how do I graph it.Ellis ShamashFri, 11 Aug 2017 19:00:24 +0200https://ask.sagemath.org/question/38506/
- How to plot a complicated function in Sage Mathhttps://ask.sagemath.org/question/38159/how-to-plot-a-complicated-function-in-sage-math/I apologize in advance for my lack of knowledge and understanding of sage.
In principle what I want to achieve is the visualization of this function:
$$ g \mapsto \left|x - \lfloor{x}\rfloor - \frac{1}{2} \right| $$
$$f(x) := \sum_{j=0}^\infty 2^{-j}g(2^jx)$$
Though I am having trouble finding out how to do this. In the documentation I did not find any easy way to handle infinite series.
I am sure this would be very helpful to many that struggle with a math problem and need to see it to believe it. A conventional plotting program will not work here, hence I searched for a better tool and found Sage Math.
Is it possible in sage? Do you have any TLDR material that I could look into?
Thank you for your help.
FragmenterSat, 01 Jul 2017 20:04:42 +0200https://ask.sagemath.org/question/38159/
- Plotting poset with vertices replaced by graph plotshttps://ask.sagemath.org/question/36930/plotting-poset-with-vertices-replaced-by-graph-plots/Hello ask.sagemath! I'd like to graph a poset of all connected graphs on $4$ vertices with the relation of $\subset$.
So far I can either draw all such graph using
L = filter(lambda g : g.is_connected(), graphs(4));
graphs_list.show_graphs(L)
Or draw a Poset with
Poset((["a","b","c"],[["a","c"],["b","c"]])).show();
But I can't combine them to, say, have
g1=Graph([(1,2),(2,3)]);
g2=Graph([(1,2),(1,3)]);
g3=Graph(networkx.complete_graph(3));
Poset([g1,g2,g3],[[g1,g3],[g2,g3]).show();
Is there a way to draw a poset where the vertices are also drawn to be graphs?
Thank you for your help!GrumpyChucklesMon, 13 Mar 2017 19:28:20 +0100https://ask.sagemath.org/question/36930/
- Parametric plot with piecewise inputhttps://ask.sagemath.org/question/35404/parametric-plot-with-piecewise-input/ I'm trying to plot a parametric function, which is defined piecewise. For some reason, the plot just jumps to the last piece of the parametric function and plots that.
Here's what I want to plot.
t = var('t')
r = 2
def f(x):
if 0 <=x <=r:
return (x, -r)
elif r<x<=r + pi*r:
return (cos(x-r), -(r + sin(x-r)))
elif r + pi*r < x <= 3*r + pi*r:
return (-x + 2*r + pi*r, r)
elif 3*r + pi*r < x <= 3*r + 2*pi*r:
return (cos(x - 3*r), -(r + sin(x-r)))
else:
return (x - 4*r - 2*pi*r, -r)
parametric_plot(f(t), (t, 0, 4*r + 2*pi*r))
It just returns a straight line of length 4*r + 2*pi*r with y coordinate -rjford1906Thu, 03 Nov 2016 20:33:56 +0100https://ask.sagemath.org/question/35404/
- visualizing logistic population growthhttps://ask.sagemath.org/question/34279/visualizing-logistic-population-growth/This is a followup question to [this question](http://ask.sagemath.org/question/34269/using-logistic-differential-equatin-reproducing-ti-nspire-cas-code/) where [@mforets](http://ask.sagemath.org/users/8657/mforets/) helped me translate some Ti Nspire code to Sagemath code. I now have following,
t = var('t')
y = function('y')(t)
ye = desolve(diff(y,t) == 2*10^(-5)*y*(1500-y), y, ics=[0,50])
ye = ye*3/100
yt = solve(ye.simplify_log(), y)
show(expand(yt))
Now I'm interested to visualize this result, reproducing some lecture notes. I looked at the examples given in the [Sage Quickstart for Differential Equations](http://doc.sagemath.org/html/en/prep/Quickstarts/Differential-Equations.html), but I cold not reproduce what was there with my example.
My lecture notes has a lot like this that I'm aim at
![image description](http://i.stack.imgur.com/fq08X.png)
By copying the right hand side (code below figure) manually I can get this, but I feel like I'm missing something;
![image description](http://i.stack.imgur.com/Zmuuw.png)
P = plot((1500*e^(3/100*t)/(e^(3/100*t) + 29)),t,0,250, color='red')
L = line([(0,1500), (260,1500)], linestyle=":", color="grey")
show(P+L, figsize=5)etbSun, 31 Jul 2016 15:47:27 +0200https://ask.sagemath.org/question/34279/
- pdfTeX warning: multiple pdfs with page group included in a single pagehttps://ask.sagemath.org/question/34183/pdftex-warning-multiple-pdfs-with-page-group-included-in-a-single-page/Hello!
I try to add two PDF plots made in Sage on a single page and pdflatex gives me the following warning:
pdfTeX warning: pdflatex (file ./sage2.pdf): PDF inclusion: multiple pdfs with
page group included in a single page
The plots are produced with:
plot(sin, 0, 4 * pi).save(r'/tmp/sage1.pdf', figsize=(2, 2))
plot(cos, 0, 4 * pi).save(r'/tmp/sage2.pdf', figsize=(2, 2))
And the LaTeX document is:
\documentclass[12pt]{article}
\usepackage{graphicx}
\begin{document}
\includegraphics{sage1}
\includegraphics{sage2}
\end{document}
The resulting document is OK, but the warning is pretty annoying. Is there any way to get rid of this warning? (Except putting plots on a separate pages)
EugeneFri, 22 Jul 2016 11:54:24 +0200https://ask.sagemath.org/question/34183/
- Is there a native equivalent/wrap to a pcolor from matplotlib in Sage?https://ask.sagemath.org/question/31514/is-there-a-native-equivalentwrap-to-a-pcolor-from-matplotlib-in-sage/ I would like to create a flat surface from data points like in [this matplotlib example](http://matplotlib.org/examples/pylab_examples/pcolor_demo.html).EugeneSat, 12 Dec 2015 13:50:55 +0100https://ask.sagemath.org/question/31514/
- How do I plot the magnitude of a complex-valued function?https://ask.sagemath.org/question/29760/how-do-i-plot-the-magnitude-of-a-complex-valued-function/My script is like this
<code>
v = var('v')
assume(v,'complex')
G = matrix([[0,1,0,0],[-v,1-v,0,0],[0,-v,1-v,0],[0,0,1,0]])
eigs = G.eigenvalues()
f1(v) = abs(eigs[0])
plot(f1,(-1,7))
</code>
The first eigenvalue is complex in a certain region and real elsewhere.
But it does not plot those portions of the plot where the eigenvalue becomes complex. What gives?
My plot is broken where the eigenvalue is complex, with the error:
verbose 0 (2717: plot.py, generate_plot_points) WARNING: When plotting, failed to evaluate function at 140 points.
verbose 0 (2717: plot.py, generate_plot_points) Last error message: 'math domain error'
What I want to do is observe the behavior of the magnitude of the eigenvalue with respect to v, irrespective of whether the eigenvalue is real or complex.
If I try
<code>
G = matrix(CC, [[0,1,0,0],[-v,1-v,0,0],[0,-v,1-v,0],[0,0,1,0]])
</code>, I get an error.AdityaSun, 04 Oct 2015 20:41:07 +0200https://ask.sagemath.org/question/29760/
- Floating plots in notebook?https://ask.sagemath.org/question/26575/floating-plots-in-notebook/ Is there a way to make plots float? Like in floating divs? Say, I have a two plots:
plot(sin, 0, pi).show()
plot(cos, 0, pi).show()
Right now this code produces two pictures, one on top of the other:
--------
|plot 1|
--------
|plot 2|
--------
But my screen is wide enough to show them alongside like:
----------------
|plot 1| plot 2|
----------------
It would be nice to have an option allowing to produce a few floating divs from pictures.EugeneFri, 17 Apr 2015 00:40:52 +0200https://ask.sagemath.org/question/26575/
- Phase portraits of 2-dimensional systemshttps://ask.sagemath.org/question/9423/phase-portraits-of-2-dimensional-systems/I'm trying to plot solutions to two dimensional ordinary differential equations. I found that Sage makes it easy to plot a vector field and, using `ode_solver()`, I can plot solutions on top of the vector field by specifying an initial condition `y_0` and some range of time to run (`t_span`).
However, this method I'm using seems to be quite ad hoc, as I have to choose the right initial conditions and time span / know a lot about my system in order to plot a nice picture. Let's make this more concrete:
Say I want to draw a nice phase portrait for
$\dot{x} = -y$
$\dot{y} = -x$
First I generate the vector field:
var('x y')
VF=plot_vector_field([-y,-x],[x,-2,2],[y,-2,2])
Then I use `ode_solver()` to plot solutions with initial conditions going around the unit circle:
T = ode_solver()
T.function=lambda t,y:[-y[1],-y[0]]
solutions = []
c = circle((0,0), 1, rgbcolor=(1,0,1))
for k in range(0,8):
T.ode_solve(y_0=[cos(k*pi/4),sin(k*pi,t_span=[0,1],num_points=100)
solutions.append(line([p[1] for p in T.solution]))
This generates the following picture:
![](http://oi46.tinypic.com/27y4v80.jpg)
But if I change run the system for one more unit of time (set `t_span=[0,2]`), the picture gets skewed:
![](http://oi49.tinypic.com/2mfj1i8.jpg)
This makes sense, of course, because the magnitude of the vectors along $y=-x$ get big as you get further away from the origin. Similarly, the trajectory along $y=x$ has trouble getting to the origin because the magnitude of those vectors get very small. Which all makes me think there's a better way to do this. Thoughts?dxvxdSun, 14 Oct 2012 15:02:40 +0200https://ask.sagemath.org/question/9423/
- Polar plot by points? (i.e. polar_line?)https://ask.sagemath.org/question/26044/polar-plot-by-points-ie-polar_line/ Hello!
If one operates in cartesian coordinates and has a function, he can plot it using *plot*. If it is a data points one can consider using *line* function. Accordingly, if we operate in polar coordinates, for the function plotting we have *polar_plot*, but what if we have only data points and we need them to be plotted in polar axes? Like, if we have an array of $[\phi_i, r_i]$.
I didn't find anything appropriate (tried polar_line and line(polar=True)) so I wrote:
def polar_line(polar_points, **kwds):
return line([(r * cos(phi), r * sin(phi)) for r, phi in polar_points], **kwds)
I am wondering is there anything default in sage for plotting in polar axes by data points?EugeneFri, 06 Mar 2015 13:45:48 +0100https://ask.sagemath.org/question/26044/
- AttributeError: must give both plot endpointshttps://ask.sagemath.org/question/25138/attributeerror-must-give-both-plot-endpoints/ I use this piece of code in my project:
print h
print h(3.2)
print parent(h)
plot(h(x) , (-4,4), thickness=2, color='green' )
and this is my output:
2.14250281996159*x + 1.74284059736793
8.59884962124501
Univariate Polynomial Ring in x over Real Field with 53 bits of precision
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "_sage_input_231.py", line 10, in <module>
exec compile(u'open("___code___.py","w").write("# -*- coding: utf-8 -*-\\n" + _support_.preparse_worksheet_cell(base64.b64decode("cHJpbnQgaApwcmludCBoKDMuMikKcHJpbnQgcGFyZW50KGgpCnBsb3QoaCh4KSAsICgtNCw0KSwgdGhpY2tuZXNzPTIsIGNvbG9yPSdncmVlbicgKQ=="),globals())+"\\n"); execfile(os.path.abspath("___code___.py"))
File "", line 1, in <module>
File "/var/sage/tmp2yTHkg/___code___.py", line 6, in <module>
exec compile(u"plot(h(x) , (-_sage_const_4 ,_sage_const_4 ), thickness=_sage_const_2 , color='green' )" + '\n', '', 'single')
File "", line 1, in <module>
File "/opt/sage/sage-6.3/local/lib/python2.7/site-packages/sage/misc/decorators.py", line 705, in wrapper
return func(*args, **kwds)
File "/opt/sage/sage-6.3/local/lib/python2.7/site-packages/sage/misc/decorators.py", line 550, in wrapper
return func(*args, **options)
File "/opt/sage/sage-6.3/local/lib/python2.7/site-packages/sage/plot/plot.py", line 1163, in plot
G = funcs.plot(*args, **original_opts)
File "polynomial_element.pyx", line 286, in sage.rings.polynomial.polynomial_element.Polynomial.plot (build/cythonized/sage/rings/polynomial/polynomial_element.c:5907)
AttributeError: must give both plot endpoints
Why does this happen ? I have specified my endpoints right? so why is it saying I didn't ? I tried a lot to solve this but i can't get it solved.. anyone who can tell me whats wrong ?
Thanks in advancegelatine1Fri, 05 Dec 2014 16:14:56 +0100https://ask.sagemath.org/question/25138/
- Plotting parametric matrix discriminantshttps://ask.sagemath.org/question/24881/plotting-parametric-matrix-discriminants/Greetings, I am struggling with the problem concerting characteristic polynomial determinants. I'm intending to plot curves in the (a,b)-plane of parametric matrices, which signal the points of some eigenvalues being zero. To this end, I use the following code
var('a b')
A = matrix([[a+sqrt(-1)b,-1,0],[-1,0,-1],[0,-1,a-sqrt(-1)b]])
p=A.charpoly('t')
d=p.discriminant()
region_plot(d>=0, (a,-4,1), (b,-4,1),incol='gray',figsize=5,axes=true)
which however produces the error
File "handle_error.pyx", line 90, in sage.libs.pari.handle_error._pari_handle_exception (build/cythonized/sage/libs/pari/handle_error.c:1178) sage.libs.pari.gen.PariError: incorrect type in gtofp
Printing the discriminant explicitly and then plotting it works fine
var('a b')
A = matrix([[a+sqrt(-1)*b,-1,0],[-1,0,-1],[0,-1,a-sqrt(-1)*b]])
p=A.charpoly('t')
d=p.discriminant()
d2=-4*b^2*a^4 + (-8*b^4 - 40*b^2 + 4)*a^2 + (-4*b^6 + 24*b^4 - 48*b^2 + 32)
region_plot(d2>=0, (a,-2,2), (b,-2,2),incol='gray',figsize=5,axes=true)
although both quantities seem to be of the same type
<type 'sage.symbolic.expression.Expression'>
any ideas about what am I missing?mamuteekSun, 16 Nov 2014 12:35:12 +0100https://ask.sagemath.org/question/24881/
- xkcd and matplotlibhttps://ask.sagemath.org/question/11366/xkcd-and-matplotlib/<p>Hi guys. Attempting to use the xkcd graphics feature that has been recently added to matplotlib from within sagemath.</p>
<p>import matplotlib.pyplot<br>
matplotlib.pyplot.xkcd()<br>
plot(sin(x),(x,-pi,pi),ticks=pi/4,tick_formatter=pi)</p>
<p>Matplotlib throws the following warning: </p>
<p><i>/home/joal/bin/sage-6.2/local/lib/python2.7/site-packages/matplotlib-1.3\
.1-py2.7-linux-x86_64.egg/matplotlib/font_manager.py:1236: UserWarning:
findfont: Font family ['Humor Sans', 'Comic Sans MS'] not found. Falling
back to Bitstream Vera Sans
(prop.get_family(), self.defaultFamily[fontext])) </i></p>
I have installed Humor Sans.ttf onto the main system, and into the directory: <br>
<i>/home/joal/bin/sage-6.2/local/lib/python2.7/site-packages/matplotlib-1.3.1-py2.7-linux-x86_64.egg/matplotlib/mpl-data/fonts/</i>
... but don't know how to reset the matplotlib font cache so matplotlib will pay attention to the new font.
----------
[EDIT]
<p>Okay, seem to have part of the solution - need to verify on a Linux machine this weekend.</p>
<p>EDIT of EDIT<br>
The tricks below don't work on LinuxMint.</p>
<p>The font is recognised in the virtualbox image if it is dumped into:<br>
<i>sage-6.2/local/lib/python2.7/site-packages/matplotlib-1.3.1-py2.7-linux-x86_64.egg/matplotlib/mpl-data/fonts/</i><br>
and renamed <i>Humor-Sans.ttf</i></p>
<p>Then you need to create a .matplotlib folder in the user directory.<br>
<i>mkdir ~/.matplotlib</i></p>
<p>The concern is that it now that Humor Sans is used for text font, but not for the numbers on the horizontal and vertical axes. Any suggestions, sagers?</p>
----------
[EDIT]
<p>Which turns out to be a consequence of using the pi tick_formatter.</p>JoalHeagneyTue, 13 May 2014 05:56:43 +0200https://ask.sagemath.org/question/11366/
- Cyrillic text on the plothttps://ask.sagemath.org/question/11355/cyrillic-text-on-the-plot/Is it possible to add the Cyrillic text to the plot in Sage Notebook?
Currently I am trying to do somethink of this kind:
total_plot = plot(sin(x),-10,10)
total_plot += text("????????", (5,0.5))
total_plot.show(figsize=(4,3))
Sage gives the error message:
ValueError: matplotlib display text must have all code points < 128
or use Unicode strings
If I add the 'u' symbol before the string
total_plot += text(u"????????", (5,0.5))
I can only see the empty rectangles instead of the letters.
P.S. I saw [this question](http://ask.sagemath.org/question/1335/cyrillic-in-matplotlib), however, I am more interested in not using Matplotlib directly if possible.v_2eSun, 13 Apr 2014 13:52:33 +0200https://ask.sagemath.org/question/11355/
- Plotting Grid Graphhttps://ask.sagemath.org/question/11046/plotting-grid-graph/I'm trying to plot a grid graph, specifying exactly where vertices should be plotted. (I want the plot to look like an actual grid and later overlay a graphics object on it.) The following code gives a KeyError:
G=graphs.GridGraph([8,12])
pos_list=[(i,j) for i in range(8) for j in range(12)]
pos_dict={}
for i in range(len(pos_list)):
pos_dict[i]=pos_list[i]
G.show(pos=pos_dict)
How can I get my plot to look like a regular grid?
jaiaSun, 16 Feb 2014 13:22:52 +0100https://ask.sagemath.org/question/11046/
- Points making up a plothttps://ask.sagemath.org/question/11344/points-making-up-a-plot/I'd like to get the list of points that make up a sage plot so I can process it through LaTeX (eg pgfplots) and get a better looking plot. This post [here](http://ask.sagemath.org/question/1710/get-list-of-coordinates-from-plot-object) is essentially what I'm looking. I didn't really understand the code but came up with this:
x,y=var('x,y')
f(x,y)=x^2-y^2
p = implicit_plot(f(x,y)==3,(x,-3,3),(y,-3,3),plot_points=300)
P = p.matplotlib()
R = P.get_children()[1]
S = R.collections[0]
r = S.get_paths()[0]
v = r.vertices
xvals = v[:,0]
yvals = v[:,1]
Change the function to f(x,y)=x^2+y^2 and the code works properly. But the example above only gives me the list of points for the left half of the hyperbola. How can I get the list of points when the graph is disconnected? Can that be extended to get the list of points if there are multiple graphs in the same plot? dazedANDconfusedSun, 23 Mar 2014 03:31:54 +0100https://ask.sagemath.org/question/11344/
- Getting plot datahttps://ask.sagemath.org/question/10882/getting-plot-data/Is there a way to extract the set of values used in a plot using sage/python code?
For example, if I have 3D surface plot, what is the best way to get the set of vertices, or the z-values, for the mesh? (and similarly for 2d plots) I've looked through some of the plotting source code but haven't found a straightforward way to access the underlying plot data.
Any tips would be appreciated!rmp251Wed, 08 Jan 2014 23:01:13 +0100https://ask.sagemath.org/question/10882/
- fields plot 3dhttps://ask.sagemath.org/question/10787/fields-plot-3d/In sagemath CLOUD i can't plot vector fields in 3d :
x,y,z = var ('x y z')
plot_vector_field3d((x*cos(z),-y*cos(z),sin(z)), (x,0,pi), (y,0,pi), (z,0,pi),center_arrows=True,aspect_ratio=(1,2,1))
error reported:
Error in lines 2-2 Traceback (most recent call last): File "/mnt/home/WmaalNmo/.sagemathcloud/sage_server.py", line 668, in execute exec compile(block+'\n', '', 'single') in namespace, locals File "", line 1, in <module> File "/mnt/home/WmaalNmo/.sagemathcloud/sage_salvus.py", line 2723, in displayhook show(obj) File "/mnt/home/WmaalNmo/.sagemathcloud/sage_salvus.py", line 2082, in show graphics.show_3d_plot_using_threejs(obj, **kwds) File "/mnt/home/WmaalNmo/.sagemathcloud/graphics.py", line 119, in show_3d_plot_using_threejs t.add(g, **kwds) File "/mnt/home/WmaalNmo/.sagemathcloud/graphics.py", line 81, in add self._call('add_3dgraphics_obj(obj)', obj={'obj':graphics3d_to_jsonable(graphics3d), 'wireframe':jsonable(kwds.get('wireframe'))}) File "/mnt/home/WmaalNmo/.sagemathcloud/graphics.py", line 387, in graphics3d_to_jsonable handler(p)(p) File "/mnt/home/WmaalNmo/.sagemathcloud/graphics.py", line 359, in convert_combination handler(x)(x) File "/mnt/home/WmaalNmo/.sagemathcloud/graphics.py", line 365, in convert_inner handler(p.all[0])(p) File "/mnt/home/WmaalNmo/.sagemathcloud/graphics.py", line 346, in convert_line "points" : p.points, AttributeError: 'TransformGroup' object has no attribute 'points'
thank you for your help.
FĂ©lix.
fgiffuniFri, 29 Nov 2013 10:01:48 +0100https://ask.sagemath.org/question/10787/
- plotting tan()https://ask.sagemath.org/question/10725/plotting-tan/When I enter these lines:
p = plot(tan(x), x, -pi, pi)
p.show(xmin=-pi, xmax=pi, ymin=-10, ymax=10)
in cloud.sagemath, I get a graph with vertical lines at -pi/2 and pi/2.
Can someone tell me why these asymptotes are drawn? Is there a way to eliminate them?leonardoSat, 16 Nov 2013 06:25:31 +0100https://ask.sagemath.org/question/10725/
- How to plot a R graph directly in Sagehttps://ask.sagemath.org/question/10673/how-to-plot-a-r-graph-directly-in-sage/I want to plot the graph using r language in Sage. And when I put this code:
sage: png(file="myplot.png", bg="transparent")
sage: plot(1:10)
sage: rect(1, 5, 3, 7, col="white")
sage: dev.off()
---
It works, but I have to click to see the graph in a new page.
What I want is to see the graph directly without clicking.
Shaowei_SunMon, 28 Oct 2013 23:14:47 +0100https://ask.sagemath.org/question/10673/