Ask Your Question

mcirri's profile - activity

2016-12-16 02:22:02 +0200 received badge  Famous Question (source)
2015-02-24 20:57:39 +0200 received badge  Notable Question (source)
2014-06-29 21:00:40 +0200 received badge  Notable Question (source)
2014-06-29 21:00:40 +0200 received badge  Famous Question (source)
2014-06-20 17:55:19 +0200 received badge  Popular Question (source)
2013-10-08 11:47:36 +0200 received badge  Popular Question (source)
2012-08-22 05:03:40 +0200 asked a question 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 ...
(more)
2012-08-20 11:27:05 +0200 asked a question 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 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, mcirri