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.Sun, 18 Apr 2021 04:58:43 +0200xmin and xmax doesn't work within parametric plot.https://ask.sagemath.org/question/56701/xmin-and-xmax-doesnt-work-within-parametric-plot/ Restricting the range with `xmin` and `xmax` doesn't work with parametric plot. Here's the code,
cs_01 = parametric_plot([fresnel_cos(t), fresnel_sin(t)], (t, -1.5*pi, 1.5*pi), ticks=[pi/8, 0.2], tick_formatter=[pi, None], axes_labels=['$x(t)$', '$y(t)$'], axes_labels_size=1.5, plot_points=500, xmin=-pi/4, xmax=pi/4, ymin=-0.8, ymax=0.8, fontsize=12)
cs_01_text_01 = text(r'$x(t) = \int_0^t\cos(\frac{\pi u^2}{2})du$', (-pi/2,0.8), fontsize=13, color='black', bounding_box={'boxstyle':'round', 'fc':(0.9,0.9,0.9), 'ec':'w'})
cs_01_text_02 = text(r'$y(t) = \int_0^t\sin(\frac{\pi u^2}{2})du$', (-pi/2,0.4), fontsize=13, color='black', bounding_box={'boxstyle':'round', 'fc':(0.9,0.9,0.9), 'ec':'w'})
cs_01_text_03 = text('Clothoid or Cornu spiral', (0, 1.15), fontsize=14, color='black', fontweight='bold')
cs_01 + cs_01_text_01 + cs_01_text_02 + cs_01_text_03
But when provided within `show` it works,
cs_01 = parametric_plot([fresnel_cos(t), fresnel_sin(t)], (t, -1.5*pi, 1.5*pi), ticks=[pi/8, 0.2], tick_formatter=[pi, None], axes_labels=['$x(t)$', '$y(t)$'], axes_labels_size=1.5, plot_points=500, ymin=-0.8, ymax=0.8, fontsize=12) + \
text(r'$x(t) = \int_0^t\cos(\frac{\pi u^2}{2})du$', (-pi/2,0.8), fontsize=13, color='black', bounding_box={'boxstyle':'round', 'fc':(0.9,0.9,0.9), 'ec':'w'}) + \
text(r'$y(t) = \int_0^t\sin(\frac{\pi u^2}{2})du$', (-pi/2,0.4), fontsize=13, color='black', bounding_box={'boxstyle':'round', 'fc':(0.9,0.9,0.9), 'ec':'w'}) + \
text('Clothoid or Cornu spiral', (0, 1.15), fontsize=14, color='black', fontweight='bold')
cs_01.show(xmin=-pi/4, xmax=pi/4)
I don't know why it's happening. Is it supposed to work like that?debojit2178Sun, 18 Apr 2021 04:58:43 +0200https://ask.sagemath.org/question/56701/show command latexhttps://ask.sagemath.org/question/54132/show-command-latex/I use sage both within the cocalc interface and the jupyter interface. The show() command behaves differently in each and I'm trying to understand. Here's an example in cocalc:
https://drive.google.com/file/d/1ZVMg5d3DMKGsXLfWcrZmBZm19yTH8G2L/view?usp=sharing
The same example in jupyter:
https://drive.google.com/file/d/1ZXaNv44HEpzSoyG6pz6I_PVKkwEd1_YH/view?usp=sharing
The in-line latex in cocalc is rendered nicely, the same latex in jupyter isn't. I've included the %display latex directive in the jupyter example, but it doesn't seem to make a difference.UncountableSetFri, 06 Nov 2020 18:05:38 +0100https://ask.sagemath.org/question/54132/Unbrackable blanckhttps://ask.sagemath.org/question/54038/unbrackable-blanck/In the following code I am obliged to insert `/` to inside my fonction to obtain the desired result.
nl=3 #nombre de contraintes
nc=4 #nombre de variables
ring=QQ
A=matrix(ring,nl,nc,[1.5,2,4,3,4,1,2,1,2,3,1,2])
b=vector(ring,[550,700,200])
c=vector(ring,[4,6,3,1])
### code ####
def simplex_tableau_sf(A, b, c,cond=1) :
# A matrice des contraintes
# b vecteur des contraintes
# c vecteur des paramètres de l'objectif
# 1 (défaut) tableau
I=identity_matrix(A.nrows())
L=block_matrix([[A,I]],subdivide=False)
L=L.augment(b)
n=A.nrows()
m=A.ncols()
z1=vector([0 for i in range(n+1)])
c=flatten(-c)
z1=flatten(z1)
zc=vector(c+z1)
L=matrix(L.rows()+[zc])
rows = list(L)
hr=['$x_{}$'.format(i) for i in range(0,nc+nl)]
hr=list('')+list(hr)+list('b')
hc=list('xc2')+['$x_{}$'.format(i) for i in range(4,7)]
t = table(rows, header_row=hr, header_column=hc, frame=True)
if cond == 1 :
return t
elif cond != 1 :
return L
So is there a blank which can be used as a stringCyrilleMon, 26 Oct 2020 18:21:08 +0100https://ask.sagemath.org/question/54038/show result in colorhttps://ask.sagemath.org/question/53425/show-result-in-color/I would like to use `show(LatexExpr(r"\text{blabla}"), result)` in such a way that `result` be in an html specific color. Is there a way to do this ?CyrilleSat, 12 Sep 2020 19:31:02 +0200https://ask.sagemath.org/question/53425/Show both sides of a function definitionhttps://ask.sagemath.org/question/51946/show-both-sides-of-a-function-definition/When I define a function and show on it, I only get the right hand side. Is there a way to show the full definition? Basically I want to show pretty-printed version of the code used to define the function. I'm using a Jupyter notebook. I could simply rewrite it in a markdown cell of course, but that's tedious and error-prone my real use-case which is more complex than this toy example.
f(x) = a*x^2 + b*x + c
show(f)
What I get:
𝑥 ↦ 𝑎𝑥<sup>2</sup>+𝑏𝑥+𝑐
What I want:
f(𝑥) = 𝑎𝑥<sup>2</sup>+𝑏𝑥+𝑐vinaypaiSat, 13 Jun 2020 19:01:25 +0200https://ask.sagemath.org/question/51946/Is the fonts displayed in the show() command sizablehttps://ask.sagemath.org/question/51782/is-the-fonts-displayed-in-the-show-command-sizable/When I typeset `?show()` i am naturally redirected to`pretty_print. It seems to be able to change font
F = random_matrix(RR,7,50)
show(F[0],fontsize="4")
but whichever be the number I cannot see any diminution in size.CyrilleSat, 06 Jun 2020 09:27:35 +0200https://ask.sagemath.org/question/51782/I can't show special charactershttps://ask.sagemath.org/question/48098/i-cant-show-special-characters/ Hi everyone! Thank you in advance for your time. I'm working in Ubuntu 18.04 and Sagemath 8.1. I want to show a string with special characters, like accents. I don't have problems with printing something like "á" in my Jupyter notebook, but when I use show, I get something like this
`PGh0bWw+PHNjcmlwdCB0eXBlPSJtYXRoL3RleDsgbW9kZT1kaXNwbGF5Ij5cbmV3Y29tbWFuZHtcQm9sZH1bMV17XG1hdGhiZnsjMX19XHZlcmJ8w6F8PC9zY3JpcHQ+PC9odG1sPg==`
How can I fix this? If somebody could help me, I'll appreciate that too much.
jdk2pySun, 29 Sep 2019 21:16:03 +0200https://ask.sagemath.org/question/48098/weird behavior of show commandhttps://ask.sagemath.org/question/48051/weird-behavior-of-show-command/ Hi The code
f(x,y)=x^3-x^2 + y^2;print f
g1 = contour_plot(f(x,y),(x,-2,2),(y,-2,2),contours=20,fill=False,cmap='spectral')
show(g1)
produces a plot with a hyperbolic point. On my computer, repeating this
show(g1)
yields a different plot
The purpose was to show this together with gradient field
f(x,y)=(x+2)^2/(y^2+ (x-1/2)^2) ;print f
g1 = contour_plot(f(x,y),(x,-2,6),(y,-2,4),contours=[1/10,1/2,4/5,1,2,3],cmap='spectral',fill=False)
df=f.gradient()
show(df)
g2 = plot_vector_field(df,(x,-2,2),(y,-2,2))
This doesn't work, since the first plot is incorrect
show(g1+g2)florinWed, 25 Sep 2019 10:34:10 +0200https://ask.sagemath.org/question/48051/dimensions of imagehttps://ask.sagemath.org/question/45765/dimensions-of-image/ I am having a little trouble when trying to specify the dimensions of a poset which I wish to see the graph of. I use name.show(figsize=[x,y]) but it's not giving me the expected image since it's only conserving the ratio, so it leaves off the y variable. If I wish to see the graph of the poset with dimensions 8x10, it should let me do so with the option figsize=[8,10], but it does not.
Can anyone help me with this issue?
Thank you in advance.StivenTue, 12 Mar 2019 02:10:26 +0100https://ask.sagemath.org/question/45765/Change dimensions of graphhttps://ask.sagemath.org/question/45761/change-dimensions-of-graph/ I am having trouble when trying to define the dimensions of a graph. I wish to have the graph of a poset with dimesions 8x10 (8in length and 10in width) but I don't know how. I tried figsize=[8,10] but it did not work since all it does is conserve the ratio.
Any given help is much appreciated. Thank you.StivenMon, 11 Mar 2019 19:46:42 +0100https://ask.sagemath.org/question/45761/Pretty print output in Jupyter notebookhttps://ask.sagemath.org/question/45481/pretty-print-output-in-jupyter-notebook/ <p>In order to provide meaningful results to my students in a Jupyter notebook, I would like to pretty print some output, including text, LaTeX and things computed by Sage. I have found that I could combine either <code>show</code> (or <code>pretty_print</code>) and <code>html</code>, or <code>show</code> and <code>LatexExpr</code>. For example,
either</p>
<pre><code>limit = r"\displaystyle\lim_{x\to0}\frac{\sin x}{x}="
value = lim(sin(x)/x, x=0)
show(html("Solucion: "+"${}={}$".format(limit,value)))
</code></pre>
<p>or, instead,</p>
<pre><code>limit = r"\displaystyle\lim_{x\to0}\frac{\sin x}{x}="
value = lim(sin(x)/x, x=0)
show("Solucion: ", LatexExpr(limit), value)
</code></pre>
<p>I would ask the following questions:</p>
<ol>
<li>Is there any reason to prefer one approach to the other?</li>
<li>If I replace <code>"Solucion"</code> by <code>"Solución"</code> (please note the accented <code>ó</code>), which is the correct way to write this Spanish word, in both approaches I get meaningless letters instead of the expected output. If I use <code>u"Solución"</code>, then Sage raises the error <code>'ascii' codec can't encode character u'\xf3' in position 6: ordinal not in range(128)</code>. Is there a way to use non-English characters?</li>
</ol>
I am using SageMath 8.5 on a MacBook Pro with macOS High Sierra. JuanjoSun, 17 Feb 2019 17:00:45 +0100https://ask.sagemath.org/question/45481/MatrixPlots with cell entrieshttps://ask.sagemath.org/question/41234/matrixplots-with-cell-entries/ Is there a nice way to combine `MatrixPlot` with something else to have a label in each cell such as in this picture?
![image description](https://i.stack.imgur.com/bgNdN.png)jepstraThu, 22 Feb 2018 18:19:50 +0100https://ask.sagemath.org/question/41234/Parametric 3d plot not showinghttps://ask.sagemath.org/question/39233/parametric-3d-plot-not-showing/ If I write `somePlot=parametric_plot3d((sin, cos, lambda u: u/10), (0,20))
somePlot.show()
`
Into a .sage file and therafter write `sage file.sage` it will not show anything. While if I run sage interactively from the terminal and write the same it will open jmol viewer and show the file. Why does this happen?PoetastropheFri, 20 Oct 2017 17:02:44 +0200https://ask.sagemath.org/question/39233/What is the difference between show() and view() in sage?https://ask.sagemath.org/question/36047/what-is-the-difference-between-show-and-view-in-sage/What is the difference between show() and view() in sage?
`A=matrix([v1,v2,v3]);show(A); view(A)`
looks like the same... is there any difference between these two?
For the screen shot [click here.](https://drive.google.com/file/d/0B62JR2iJ8Ep_T09Gel9GSG9kM2M/view?usp=sharing)
![image description](https://drive.google.com/file/d/0B62JR2iJ8Ep_T09Gel9GSG9kM2M/view?usp=sharing)daviddglSun, 18 Dec 2016 17:56:30 +0100https://ask.sagemath.org/question/36047/Why show() is not working when we are using with print?https://ask.sagemath.org/question/35806/why-show-is-not-working-when-we-are-using-with-print/Why show() is not working when we are using with print?
---
I have written a program to find a matrix as a result.
When I have finished and was tring to polish the output, I ended up the situation to use,
`print " The matrix is ", show(A)`
The output is just
> The matrix is
its not giving the matrix.
if I use show() without print function, its giving the matrix.
How to fix this issue??
Thanks for helping..
Workdone:
---
As [William Stein](https://ask.sagemath.org/question/33593/show-does-not-show-in-the-right-place/) has given in his answer, I have used,
sys.stdout.flush()
after print function. But it didnt help me.
I will give my subroutine, since if there is any bug in the code also give a bug in show() funciton.
A=matrix(Integers(12),[[1,0,3,1],[0,2,0,3],[0,0,6,1],[0,0,0,2]])
S24=[[0,1],[0,2],[0,3],[1,2],[1,3],[2,3]]
C2=zero_matrix(Integers(12),6,6)
for i in range(6):
for j in range(6):
C2[i,j]=A.matrix_from_rows_and_columns(S24[i],S24[j]).det()
print "The compound matrix C2(A)=", '\n'
sys.stdout.flush()
show(C2)daviddglWed, 30 Nov 2016 03:34:53 +0100https://ask.sagemath.org/question/35806/Redirecting the output of show() to a file?https://ask.sagemath.org/question/34675/redirecting-the-output-of-show-to-a-file/Consider the tree
t = Permutation([1, 3, 2, 6, 8, 9, 5, 7, 4]).increasing_tree().as_ordered_tree()
show(t)
The output is a TeX-tikzpicture. I want to post-process this
picture at the TeX level (for a motivation see my last question).
To do so I have to manually copy and paste the output in some
editor. It would be much easier if I could redirect the output
into a text file and proceed from this file.
Is it possible to do so?Peter LuschnyThu, 01 Sep 2016 10:47:53 +0200https://ask.sagemath.org/question/34675/Can I show ordered sets in order?https://ask.sagemath.org/question/34369/can-i-show-ordered-sets-in-order/ I'm using SageTex to generate random algebra tests, with an answer key at the end. To have my students show they understand roster notation for sets, I'm having them write the set of all two-digit multiples of n for some number n in {2, 3, 4, ... 9}. Asking the question isn't hard. But in generating the answer key, the set shows up in random order. I know it's still the same set, of course, but it's less intuitive to interpret. It seems like Sage is going out of it's way to randomize the set. Here's some minimal working code:
n = Set(range(2, 10)).random_element()
X = Set()
for i in range(10, 100):
if i % n == 0:
X = X.union(Set([i]))
show(n)
show(X)
This shows, for example:
8
{32, 64, 48, 40, 80, 96, 16, 24, 56, 72, 88}
Is there some way to have Sage show the elements of the set in order?mathochistMon, 08 Aug 2016 02:13:27 +0200https://ask.sagemath.org/question/34369/show() does not show in the right placehttps://ask.sagemath.org/question/33593/show-does-not-show-in-the-right-place/ Why the show() funtion does not show in the right position?
It should show between the BEFORE and AFTER prints, but actually if you run the code, it will appear right before the first print (see the code): print ("BEFORE SHOW ", i)
print ("Create a graph")
G = Graph(sparse=True)
G.allow_multiple_edges(True)
G.add_edge(1,2,"blue")
G.add_edge(2,3,"green")
G.add_edge(3,1,"red")
G.add_edge(1,4,"green")
G.add_edge(2,4,"red")
G.add_edge(3,4,"blue")
for i in range(5):
print ("BEFORE SHOW ", i)
show(G)
print ("AFTER SHOW ", i)
print ("BEFORE PLOT ", i)
G.plot()
print ("AFTER PLOT ", i)stefanuttiTue, 31 May 2016 10:36:00 +0200https://ask.sagemath.org/question/33593/Display symbolic expressions without expansionhttps://ask.sagemath.org/question/32729/display-symbolic-expressions-without-expansion/I'm trying to write symbolic expressions with many intermediate variables. When I use the "show" function to display the final symbolic expression, it always shows the expression with the intermediate variables fully expanded. How can I show the final expression in terms of intermediate variables? Here is a simplified example:
var('t')
cc=matrix(SR, 3, 3, t)
I1=cc.trace()
Q=exp(I1)
show(Q)
With the above code, the output would be
\begin{equation}
Q=e^{3t}
\end{equation}
How can I generate an output as
\begin{equation}
Q=e^{I1}
\end{equation}
LiangMon, 07 Mar 2016 21:12:02 +0100https://ask.sagemath.org/question/32729/Does Sage show steps to solving an equation?https://ask.sagemath.org/question/8042/does-sage-show-steps-to-solving-an-equation/Like how mathematica has the trace function or wolframalpha has in their features? Sometimes wolfram alpha isn't able to show steps for certain problems. I feel this feature is important to me understanding and learning a problem.
Thanks. Nanogear1014Fri, 01 Apr 2011 05:32:55 +0200https://ask.sagemath.org/question/8042/Graph: colored edge labelshttps://ask.sagemath.org/question/25413/graph-colored-edge-labels/I'm trying to plot a graph with labels on the edges as follows:
G = Graph(multiedges=True)
G.add_edges( [(0,1,'a'),(1,2,'b'),(2,3,'c'),(3,4,'b'),(4,0,'a')] )
H = G.plot(edge_labels=True, graph_border=True)
H.show()
Is it possible to color the edge labels, e.g. making the "a" red, "b" blue etc?
herbTue, 06 Jan 2015 20:10:47 +0100https://ask.sagemath.org/question/25413/Missing close bracehttps://ask.sagemath.org/question/25130/missing-close-brace/hi!
Im getting "Missing close brace" when I try to prettyprint an expression on sage cloud.
the expression Im trying to prettyprint using show() is the result of using solve() on an equation system and saving it in the variable "a", I can see the contents of "a" but I can't prettyprint it.
![image description](http://s21.postimg.org/t1hmpsdj9/AAAAAAA.jpg)
thanks!
EDIT:
show (a[0]) works great for showing the first element, but I still cant get the whole thing to show.
here is the code that produces the error
- f=4*(x^3-x/4)^3+4*x-4*(x^3-x/4)
- solve (f==0,x)
- show (solve (f==0,x))
here is a pic
![image description](http://s13.postimg.org/nsvspkjd1/AAAAAAA.jpg)martovThu, 04 Dec 2014 22:56:05 +0100https://ask.sagemath.org/question/25130/sage.cloud'sheet is too smallhttps://ask.sagemath.org/question/24718/sagecloudsheet-is-too-small/ when run below,the code is lost
E = EllipticCurve_from_j(Qp(7,3)(0));E;html(table(E.automorphisms(),frame="True")).transpose())
show(EllipticCurve_from_j(GF(3,'a')(0)).automorphisms())cjshFri, 31 Oct 2014 05:24:29 +0100https://ask.sagemath.org/question/24718/why cloud.sage so many Undefined control sequences?https://ask.sagemath.org/question/24620/why-cloudsage-so-many-undefined-control-sequences/ old sagenb can do show(Qp(5)),show(QQbar()) and ,it is very beautil,but cloud.sage cannot
https://cloud.sagemath.com/projects/faaa84be-e0d1-451f-9517-cf6d911a9bde/files/2014-10-24-145338.sagewscjshFri, 24 Oct 2014 13:08:40 +0200https://ask.sagemath.org/question/24620/Can I get a matrix to show with brackets instead of parentheses?https://ask.sagemath.org/question/24068/can-i-get-a-matrix-to-show-with-brackets-instead-of-parentheses/I'm using Sage and SageTeX to make worksheets and quizzes for my Linear Algebra course. I'd like my presentation to match the book's, and the book uses brackets around its matrices instead of parentheses. Is that doable? Is there a way, for example, to get `latex(A)` to generate
\left[\begin{array}{rrr} 6 & 6 & 1 \\ 7 & 0 & 6 \\ 4 & -7 & -7 \end{array}\right]
instead of
\left(\begin{array}{rrr} 6 & 6 & 1 \\ 7 & 0 & 6 \\ 4 & -7 & -7 \end{array}\right)
for some matrix A.mathochistTue, 09 Sep 2014 17:28:54 +0200https://ask.sagemath.org/question/24068/"showing" both input and outputhttps://ask.sagemath.org/question/24039/showing-both-input-and-output/Is there a way to get Sage to show the "pretty" versions of both the input and the output of a calculation, instead of just the output? (sort of like the TI-89 and such)
For example, when I enter as input "integrate(x^2, x, 0, 3)" it correctly returns 9. But can I get it to return something like (the typeset version of) \int_0^3 x^2 dx = 9 ? It's obvious enough in this example what I'm asking for but some queries get complicated and seeing them as they would be printed helps make sure I'm asking Sage for what I mean to ask for.mathochistSat, 06 Sep 2014 22:41:45 +0200https://ask.sagemath.org/question/24039/when sagecell run show(),the result only above tophttps://ask.sagemath.org/question/23562/when-sagecell-run-showthe-result-only-above-top/
var('k a b c d');q=solve(k*x^4+a*x^3+b*x^2+c*x+d==0,x);q,show(q[0].simplify_full()),show(q[1].simplify_full()),show(q[2].simplify_full()),show(q[3].simplify_full())
show(q[3].simplify_full()) is the last command,but the result appear the toppest cjshThu, 24 Jul 2014 13:36:25 +0200https://ask.sagemath.org/question/23562/plt.show() and plt.draw() doesnt workhttps://ask.sagemath.org/question/23387/pltshow-and-pltdraw-doesnt-work/Hi experts!
I have a numpy array M. I generate a graph using NetworkX and then I want to draw this graph:
import networkx as nx
import matplotlib.pyplot as plt
G=nx.Graph(M)
nx.draw(G)
plt.draw()
Doing this, no picture appears. In addition, if I do `plt.show()` no picture appears neither.
If I do
import numpy as np
import matplotlib.pyplot as plt
x = np.range(0, 5, 0.1);
y = np.sin(x)
plt.plot(x, y)
no picture appears neither.
What happend?
Please help!
Best regardsmresimulatorSat, 12 Jul 2014 18:52:36 +0200https://ask.sagemath.org/question/23387/Graph theory: Make vertex labels in plots biggerhttps://ask.sagemath.org/question/9626/graph-theory-make-vertex-labels-in-plots-bigger/Is it possible to make the labels for the vertices of graphs bigger? I can make the vertices themselves bigger but that doesn't seem to change the size of the labels.
Thank you.G-SageWed, 12 Dec 2012 16:51:15 +0100https://ask.sagemath.org/question/9626/Unable to get Show() with GTK backend inside Sagehttps://ask.sagemath.org/question/10909/unable-to-get-show-with-gtk-backend-inside-sage/I am trying to do the following with GTK as the sage backend.
import matplotlib.pyplot as plt
plt.plot([1,2,3])
plt.ylabel('Numbers')
plt.show()
I am able to do this inside Python with the following:
import matplotlib
matplotlib.use('GTK')
import matplotlib.pyplot as plt
plt.plot([1,2,3])
plt.ylabel('Numbers')
plt.show()
This fails in sage which asked me to install pygtk. When I did
sage: install_package('pygtk'),
it pulled an experimental pygtk-2.8.4 which failed with the following error
-----------------
checking for gcc... gcc
checking for C compiler default output file name... configure: error: C compiler cannot create executables
See `config.log' for more details.
ERROR configuring pygtk for build!
---------------------
I do have gcc/g++ installed in /usr/bin and in /usr/local/bin/sage/local/bin
All other backends like WX or PyQt4 run into other issues. I suspect this is a problem with the pygtk spkg. If someone has a workaround for this, please send/propose it.
RBSun, 12 Jan 2014 19:54:00 +0100https://ask.sagemath.org/question/10909/