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.Wed, 16 Oct 2019 02:51:49 -0500Displaying a text before a solution and a strange behaviourhttp://ask.sagemath.org/question/48359/displaying-a-text-before-a-solution-and-a-strange-behaviour/1) Under Windows10
A=matrix(m,n,(0,1,1,0,6,18))
show($A =$,A)
This does not display with A= in latex style. How can I code what I expect ?
2) on my computer
%display latex
m=3 #nombre de contraintes
n=2 # nombre de variables
A=matrix(m,n,(0,1,1,0,6,18))
bmin=matrix(m,1,(12,0,0))
bmax=matrix(m,1,(oo,10,70))
c=matrix(1,n,(4.1,8))
show(A,bmin,bmax,c)
show(bmax)
10 and 70 are not displayed but sage substitute "$Apositivefinitenumber$"CyrilleWed, 16 Oct 2019 02:51:49 -0500http://ask.sagemath.org/question/48359/Output too long in SAGEhttp://ask.sagemath.org/question/38959/output-too-long-in-sage/I have a program whos output is too long to be displayed in the terminal where I run sage. Is there a possiblity that the output of SAGE is automatically "copied" (as if I mark it and use ctrl+c) and then I can paste it into a text file?
Or is there another way that the result can be automatically be saved into a text file or a way to make the terminal allow larger text before the text gets cut off?
Here the code Im talking about:
le_relations = lambda P: [(a,b) if P.le(a,b) else (b,a) for a,b in P.comparability_graph().edges(labels=None)]
cover_relations = lambda P: [(a,b) if P.le(a,b) else (b,a) for a,b in P.hasse_diagram().edges(labels=None)]
format_pt = lambda k: "'x{0}'".format(k+1)
format_relations = lambda relations: [[format_pt(a),format_pt(b)] for a,b in relations]
format_pts = lambda P: [format_pt(a) for a in P]
format_poset = lambda P: [format_pts(P), format_relations(cover_relations(P)), format_relations(le_relations(P))]
what_you_want = lambda n: [format_poset(P) for P in posets(n) if P.is_lattice()]
print(what_you_want(8))
It takes about 20 minits for my computer to finish the calculation while the calculation seems to never finish in the online sage cell https://sagecell.sagemath.org/.
The code is from the thread https://ask.sagemath.org/question/38865/obtaining-all-posets-in-a-certain-form-with-sage/ )
edit: Another option would be to divide the set [format_poset(P) for P in posets(n) if P.is_lattice] into smaller pieces (lets say 5 pieces) and apply the code to those smaller pieces. The set contains 222 elements. Is there a way to apply the cod to the first 40 of those elements first and then I do it seperately for the next 40 and so on till I have all. Maybe it is possible to filter instead of posets(n) (for n=8) over just the first 40 posets of posets(n) and then the next 40 and so on.sagequstionsSat, 23 Sep 2017 15:17:13 -0500http://ask.sagemath.org/question/38959/Typesetting text in TeX view()http://ask.sagemath.org/question/9041/typesetting-text-in-tex-view/Is there a standard way to typeset TeX formulas together with normal text via view()?
So far I've been using
tex_string = "\hbox{- stationary points: }"
for pt in stats:
tex_string += latex(pt)
tex_string += ", "
view(tex_string)
where `stats` is a list of some points (defined with formulas).MathemageThu, 07 Jun 2012 06:36:23 -0500http://ask.sagemath.org/question/9041/Change font size for all texts in a graphhttp://ask.sagemath.org/question/35205/change-font-size-for-all-texts-in-a-graph/Is it possible to set the font size for all labels in a plot?
I have been able to set the font family changing the internal parameters of matplotlib
from matplotlib import rc
rc('text',usetex=True)
rc('font',**{'family':'serif','serif':['Times']})
I'd like to change the size as well, so that all labels created with 'text' are the same size (note that I want to use TeX in labels)Massimo2013Thu, 20 Oct 2016 15:02:31 -0500http://ask.sagemath.org/question/35205/latex in plotshttp://ask.sagemath.org/question/33805/latex-in-plots/I want to display the formula for the graph of a function that sage has plotted without typing the expression manually, because sage has calculated it. For example the n-th Taylor polynomial expansion of a function:
f = sin(x)
g = f.taylor(x, 0, 13)
P = plot(f,(x,-10, 10), ymin =-4, ymax = 4, color="blue", axes=True, aspect_ratio=1, thickness=3)
Q = plot(g,(x,-10, 10), ymin =-4, ymax = 4, color="red", axes=True, aspect_ratio=1)
R = text(r"$%s \approx %s$" %(f,g),(0,yzoom[1]+1),rgbcolor=(1,0,0))
show(P + Q + R)
Everything works fine except for two things in the displayed formula:
1. the * s are shown (which I can live with)
2. The two digit exponents are not shown correctly which I assume it is because there are no curly brackets around them in the string g.
**Are there better ways of doing this?**
P.S. Are there ways of writing up the parts of the text in different colors, without defining two pieces of text and trying to figure out their relative positions?k1monfaredWed, 15 Jun 2016 16:05:48 -0500http://ask.sagemath.org/question/33805/Change width of rich text cells in notebookhttp://ask.sagemath.org/question/30176/change-width-of-rich-text-cells-in-notebook/With the default settings, cells in the notebook take the whole width of the window. This is annoying for rich text cells with long paragraphs, as they get very hard to read. Also if you are using LaTeX math mode, the equations will be centered on the window, which looks bad if you only have rather short lines of text surrounding them.
I would like to know if there is a way to restrict the width of the rich text cells, such that lines of text get broken earlier and readability is improved. The settings contain an option for number of word wrap columns, but it seems to have no effect whatsoever on my worksheets.tosterWed, 21 Oct 2015 03:46:45 -0500http://ask.sagemath.org/question/30176/How to print a text file containing multiple tuples from a functionhttp://ask.sagemath.org/question/26710/how-to-print-a-text-file-containing-multiple-tuples-from-a-function/ I am trying to use Sagemath Cloud to create a text file with multiple columns of data. Each column is the input or output value of the variables of a system of functions being evaluated with for loops. I am very new to Python, and when I try to do this, I either get an error message or I get a text file with only one line, and that line is constantly overwritten by a new value of the function. On my own laptop with its standalone version of Sage, I can easily generate what I want simply by telling Sage to print the values of the variables of the function for each iteration of the for loops. The standalone version even creates an output text file that I can save. How do I do this with the cloud version?C. ThompsonSun, 03 May 2015 18:42:46 -0500http://ask.sagemath.org/question/26710/How to fill rectangle around the text (or measure string)?http://ask.sagemath.org/question/26274/how-to-fill-rectangle-around-the-text-or-measure-string/ Hello!
I would like to fill a rectangle around the text on the plot, to make text more readable (same way it is done for the legend), the perfect way would be:
text('Sage!', (0, 0), fill=True, fill_color='blue', edgecolor='black')
But unfortunately there are no such options. I tried to write a custom function using text and polygon2d, but the problem appeared in calculating the size of the rectangle around the arbitrary text.
So, could anyone help me figure out how to calculate the size of the rectangle around the text (something like string measuring with consideration of font settings?), or may be suggest a better approach?EugeneFri, 20 Mar 2015 17:53:15 -0500http://ask.sagemath.org/question/26274/LaTeX in plot not showing Greek letterhttp://ask.sagemath.org/question/25209/latex-in-plot-not-showing-greek-letter/ Hello. I'm using the following code to generate an image of a triangle for a trigonometry quiz.
p = polygon2d([[0,0], [0,3], [4,0]], fill = False, axes = False)
p += text("$\theta$", (3, 0.2), fontsize = 22)
show(p)
The issue is that Sage doesn't seem to recognise $\theta$ as LaTeX, even though it's in dollar signs. In the corner of the triangle, it puts "heta". Why isn't this typesetting correctly? How can I fix it?
Thank you.mathochistWed, 10 Dec 2014 13:22:46 -0600http://ask.sagemath.org/question/25209/converting a list to a text without copy-pastinghttp://ask.sagemath.org/question/24362/converting-a-list-to-a-text-without-copy-pasting/ Hi,
I have a list and I need to convert it to a text but i want to call this list, so I don't want to copy and paste the result in text = " "
I tried text = list(U) (just assume that U is callable, so list(U) gives anything in U as a list) but it didn't work.
Can anyone suggest a way?algebraicallyclosedWed, 01 Oct 2014 05:02:41 -0500http://ask.sagemath.org/question/24362/Is it possible to call a Sage command from within a text cell in the Sage Notebook and display the output inline as latex?http://ask.sagemath.org/question/10065/is-it-possible-to-call-a-sage-command-from-within-a-text-cell-in-the-sage-notebook-and-display-the-output-inline-as-latex/I know it is possible to insert latex inline within a text cell in the Sage Notebook, but is it possible to have that being the output of a Sage command? Thanks!p1999Tue, 13 Aug 2013 22:37:07 -0500http://ask.sagemath.org/question/10065/Multiline equation write form in text cell?http://ask.sagemath.org/question/10001/multiline-equation-write-form-in-text-cell/Is there a way to write equation within text cell as few lines?
For example this:
$f(x) = y^x$
renders normally, but this:
$f(x)
=
y^x$
renders as plain text. I wan it to be rendered in the same way as first one.
P.S. I am new to latex, so trying to find a way to make complex equation in latex more readable (may be there is a better way to do it than splitting it to a few lines?).EugeneSun, 07 Apr 2013 07:54:52 -0500http://ask.sagemath.org/question/10001/Add text to Tachyon image?http://ask.sagemath.org/question/9322/add-text-to-tachyon-image/Hi folks, is there a way to add text to Tachyon images? I tried
S = sphere(opacity=0.8, aspect_ratio=[1,1,1])
T = text3d('hello world', (2,2,2))
M = S + T
M.show(viewer='tachyon', frame=False)
in the Sage notebook, but that didn't work. Got a sphere but no text. I also searched the docs, but couldn't find anything relevant.araichevSun, 16 Sep 2012 14:00:10 -0500http://ask.sagemath.org/question/9322/Save plot in SVG with plain text stringshttp://ask.sagemath.org/question/9261/save-plot-in-svg-with-plain-text-strings/Hi all,
as previously stated I am quite inexpert in using both SAGE and Python. I am trying to create figure for a LaTeX report. I am working on a machine on which I cannot use the package to integrate SAGE in LaTeX.
I am quite able to create plots and save them in SVG files. The real problem is that every caption or text in my plots appears as a embedded font or shape or whatever.
Here is an example:
TestPlot=plot(sin(x),(x,0,2*pi))+text("a stupid comment",(pi,2))
show(TestPlot)
TestPlot.save('TestPlot.svg')
This code generates the plot but when I start looking into the SVG file I can see that the caption "a stupid comment" was exported as:
<g id="text_13">
<!-- a stupid comment -->
<defs>
<path id="BitstreamVeraSans-Roman-20"/>
<path d="
M54.8906 33.0156
L54.8906 0
L45.9062 0
L45.9062 32.7188
Q45.9062 40.4844 42.875 44.3281
Q39.8438 48.1875 33.7969 48.1875
Q26.5156 48.1875 22.3125 43.5469
Q18.1094 38.9219 18.1094 30.9062
L18.1094 0
L9.07812 0
L9.07812 54.6875
L18.1094 54.6875
L18.1094 46.1875
Q21.3438 51.125 25.7031 53.5625
Q30.0781 56 35.7969 56
Q45.2188 56 50.0469 50.1719
Q54.8906 44.3438 54.8906 33.0156" id="BitstreamVeraSans-Roman-6e"/>
...
Q40.5312 48.4844 33.4062 48.4844
Q26.2656 48.4844 22.1875 42.8438
Q18.1094 37.2031 18.1094 27.2969
Q18.1094 17.3906 22.1875 11.75
Q26.2656 6.10938 33.4062 6.10938
Q40.5312 6.10938 44.6094 11.75
Q48.6875 17.3906 48.6875 27.2969" id="BitstreamVeraSans-Roman-70"/>
</defs>
<g style="fill:#0000ff;" transform="translate(241.978030233 60.4907451923)scale(0.1 -0.1)">
<use xlink:href="#BitstreamVeraSans-Roman-61"/>
<use x="61.279296875" xlink:href="#BitstreamVeraSans-Roman-20"/>
<use x="93.06640625" xlink:href="#BitstreamVeraSans-Roman-73"/>
<use x="145.166015625" xlink:href="#BitstreamVeraSans-Roman-74"/>
<use x="184.375" xlink:href="#BitstreamVeraSans-Roman-75"/>
<use x="247.75390625" xlink:href="#BitstreamVeraSans-Roman-70"/>
<use x="311.23046875" xlink:href="#BitstreamVeraSans-Roman-69"/>
<use x="339.013671875" xlink:href="#BitstreamVeraSans-Roman-64"/>
<use x="402.490234375" xlink:href="#BitstreamVeraSans-Roman-20"/>
<use x="434.27734375" xlink:href="#BitstreamVeraSans-Roman-63"/>
<use x="489.2578125" xlink:href="#BitstreamVeraSans-Roman-6f"/>
<use x="550.439453125" xlink:href="#BitstreamVeraSans-Roman-6d"/>
<use x="647.8515625" xlink:href="#BitstreamVeraSans-Roman-6d"/>
<use x="745.263671875" xlink:href="#BitstreamVeraSans-Roman-65"/>
<use x="806.787109375" xlink:href="#BitstreamVeraSans-Roman-6e"/>
<use x="870.166015625" xlink:href="#BitstreamVeraSans-Roman-74"/>
</g>
</g>
</g>
</g>
Here I have eliminated a lot of lines for sake of readability. This renders well in SVG viewers but as I convert it to pdf+LaTeX with inkscape the caption is not, of course, converted in LaTeX and thus the appearance of the report is not consistent. Is there a way to force the export to actually export a text object?
What I'd like to have is something like this:
<text
x="160.75159"
y="209.35091"
id="text2987"
xml:space="preserve"
style="font-size:10px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:Lucida Sans;-inkscape-font-specification:Lucida Sans"><tspan
x="160.75159"
y="209.35091"
id="tspan2989">\emph{some stupid comment}</tspan></text>
where, as you can see I can also use some LaTeX syntax with no problem.
Best regards,
mcirri
mcirriTue, 21 Aug 2012 22:03:40 -0500http://ask.sagemath.org/question/9261/font_family for text()http://ask.sagemath.org/question/9201/font_family-for-text/Hello!
Is the *'font_family'* option available for something other than a pot legend? In particular, I need to set the font face for the text added to a plot with the *text()* function.
Thanks!v_2eFri, 03 Aug 2012 03:14:16 -0500http://ask.sagemath.org/question/9201/Plotting a latex matrix using text()http://ask.sagemath.org/question/9155/plotting-a-latex-matrix-using-text/I would like to plot a latex'd matrix at a location in a 2d plot. I tried this:
text('$\\left( \\begin{array}{ll} 2 & 3 \\\\ 4 & 5 \\end{array} \\right)$', (1,0) )
and various variations to do with the backslashes being escaped or not. But every time I get an error:
matplotlib.pyparsing.ParseFatalException: Expected end of math '$'
$\left( \begin{array}{ll} 2 & 3 \\ 4 & 5 \end{array} \right)$ (at char 0), (line:1, col:1)
It appears that matplotlib doesn't want to parse an array or a pmatrix etc. Is there a workaround?Kate StangeSat, 14 Jul 2012 02:04:17 -0500http://ask.sagemath.org/question/9155/Save data to text file - List_plot(...).save(Path, Name..)?http://ask.sagemath.org/question/9108/save-data-to-text-file-list_plotsavepath-name/Hey,
Is there a way to save data in list plot as a text file in stead/ in addition to showing it with .show() ?
In this way - I want to export the data from my list, say to Excel or Matlab in order to plot it using their tools. I wish the data would be arrange in the text file in a list of values that I could then copy (for example) to the Excel table.
Thanking u on advance! ErezSun, 24 Jun 2012 21:42:16 -0500http://ask.sagemath.org/question/9108/Plot titleshttp://ask.sagemath.org/question/7808/plot-titles/I know about the text function, but this has to be inside the plot. How would one make titles for plots?
Thank you.Eviatar BachSat, 11 Dec 2010 18:22:02 -0600http://ask.sagemath.org/question/7808/