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.Sat, 06 Apr 2019 12:52:46 -0500Line,Plane, Points 3D, Intersection,http://ask.sagemath.org/question/46033/lineplane-points-3d-intersection/Is there a tutorial on
-analytical geometry(vectors) :
plane
line
2D circle in 3D,
plot chains of vectors, basicaly the everything what this thing can do: https://www.geogebra.org/3d?lang=de
well allmost everything in vector geometry
for python or sagemath.
Maybe someone saw a book or tutorial on this
I can not find anything on this.
I have managed to plot points
from sage.plot.plot3d.shapes2 import frame3d
F=frame3d([0,0,0],vector([10,10,10]),color='red')
A=point3d((4,3,2),size=10,color='red',opacity=.5)
e=0.2
eps=vector([4+e,3+e,2+e])
T = text3d('A',eps)
F+A+T
I didnt manage to label, point A(4,3,2), to to do it? I would rather not put the coordinates as a string. Is there something like in c++ "The point is %d"
Is there a better way to plot? I need the frame, since the plot 3d is not accepting, text, or maybe i am wrong?
Would there by a natural way to plot x,y,z axes?
Here is the Code
https://share.cocalc.com/share/a3f14e05-7729-406f-97c5-be5b73646381/vector/ebene.sagews?viewer=sharethethaSat, 06 Apr 2019 12:52:46 -0500http://ask.sagemath.org/question/46033/How to change color AFTER calling "plot"?http://ask.sagemath.org/question/45422/how-to-change-color-after-calling-plot/Suppose I have done
p = plot(x^2) + plot(x^3)
and then I decide I want the image in grayscale. Is there a way to specify this without having to re-plot again?
Thanks in advance for your answers!dsejasMon, 11 Feb 2019 13:51:38 -0600http://ask.sagemath.org/question/45422/Conditional Plot, plot f(x+iy) if g(x+iy) satisfies some kind of conditionhttp://ask.sagemath.org/question/45445/conditional-plot-plot-fxiy-if-gxiy-satisfies-some-kind-of-condition/Let's say I have two functions f(zeta) and g(zeta), and I'd like to have 3D-plot and Contour Plot of f(zeta) if g(zeta) in a certain range.
I have defined f(zeta) and g(zeta), and then I tried this command, but Sage said the syntax is not valid.
B=implicit_plot(lambda x,y : float(f(x+y*I)),if 1<g(x+y*I)<3,(-5,5),(-5,5)))
I am pretty new with Sage math, so please bear with me if the question is too trivial....
JacobsonRadicalWed, 13 Feb 2019 04:55:53 -0600http://ask.sagemath.org/question/45445/__init__() takes exactly 5 arguments (4 given) error in contour plothttp://ask.sagemath.org/question/45446/__init__-takes-exactly-5-arguments-4-given-error-in-contour-plot/ I am trying to make a contour plot of a complex valued function. Let say it is g(z).
I have imported the complex root and ContourPlot command by doing following:
from sage.rings.polynomial.complex_roots import complex_roots
from sage.plot.contour_plot import ContourPlot
I have even successfully plot the 3d-Plot, but I encountered an error stating:
__init__() takes exactly 5 arguments (4 given)
My command is:
C=ContourPlot(lambda x,y:float(green(x+y*I)),(-5,5),(-5,5))
It seems that I did not miss the fifth argument, I tried to add in some commands, such as plot_points, but then Sage said it did not expect these commands..
What did I miss? Thank you!!JacobsonRadicalWed, 13 Feb 2019 05:03:37 -0600http://ask.sagemath.org/question/45446/draw all faces of alcoves (affine root system)http://ask.sagemath.org/question/45354/draw-all-faces-of-alcoves-affine-root-system/I am trying to plot alcoves for in a rank 3 affine root system with some of those alcoves highlighted by having all faces drawn and the others only shown as a wire frame.
The manual on visualising root systems at sagemath.org is quite useful, but I have some effects show that I don't understand.
For some reason while the fundamental alcove will have all faces shown many of the others have not, that is, some faces are missing. Below you find one example code that I have done. For the chosen seq one face is missing, the red one. For other choices of seq one might even see only one face drawn. How do I force to have all faces shown?
L = RootSystem(["A",3,1]).ambient_space()
P = RootSystem(["A",3,1]).weight_space(extended=True)
Lambda = P.fundamental_weights()
W = L.weyl_group()
W0=W.classical()
plot_options = L.plot_parse_options()
seq=[2,3,1,2]
t = 1*Lambda[1]-1*Lambda[2]+1*Lambda[3]
Alcoves=[W.from_reduced_word(w.reduced_word()) for w in W0]
p = L.plot_fundamental_chamber("classical")
p += L.plot_fundamental_weights()
p += L.plot_alcoves(alcoves=Alcoves, wireframe=True)
p += L.plot_alcoves(alcoves=[W.from_reduced_word(seq)])
p += L.plot_alcoves(alcoves=[W.from_reduced_word([])])
p += plot_options.family_of_vectors({t: L(t)})
p.show(frame=False)oloidThu, 07 Feb 2019 09:08:34 -0600http://ask.sagemath.org/question/45354/show all view with same x size of Hanoi's Towershttp://ask.sagemath.org/question/45084/show-all-view-with-same-x-size-of-hanois-towers/
Hi
I did this little program to visualize all Hanoi's Towers steps in Jupyter Notebook sagemath 8.4 ,W10.
why my x-axis is not always the same width size in each view?
figsize=[figSizeXmax,figSizeYmax] does not seem to work.
how can I manage to get the same x length for each graph ?
[Code On Cocalc.com](https://cocalc.com/projects/9c478dc8-084a-43b6-aedc-e027b42adfa8/files/HanoiTower.ipynb?session=default)ortolljThu, 17 Jan 2019 13:19:37 -0600http://ask.sagemath.org/question/45084/Can't display figureshttp://ask.sagemath.org/question/44953/cant-display-figures/hello,
i installed Sage on a new computer this morning,
but i can't display any figures.
That's the error i get :
> /home/xxx/Documents/SageMath/local/lib/python2.7/site-packages/sage/\
repl/rich_output/display_manager.py:592: RichReprWarning: Exception in
_rich_repr_ while displaying object: libtk8.6.so: cannot open shared
object file: No such file or directory
RichReprWarning,
Graphics object consisting of 1 graphics primitive
Anyone got an idea why?
i'm using the notebook of sagemaths
Thanks.tommeTue, 08 Jan 2019 05:15:39 -0600http://ask.sagemath.org/question/44953/What is meant by "graphics primitive" in the sage documentation?http://ask.sagemath.org/question/44100/what-is-meant-by-graphics-primitive-in-the-sage-documentation/ I'm currently learning sage, and I keep seeing the phrase, "graphics primitive" mentioned in the manual, but I'm not quite sure what is meant by that. The closest thing I've found to a definition of it is on the page "Plotting Primitives" where it is defined as "things that know how to draw themselves in 2D". Does this just mean that a primitive is anything predefined by sage, like circles and lines? Also, are there only "graphics primitives" and not any other kind?FubwubsSat, 27 Oct 2018 18:35:38 -0500http://ask.sagemath.org/question/44100/graph vertex labellinghttp://ask.sagemath.org/question/42892/graph-vertex-labelling/I have a graph (poset actually) that has a rational function labelling each vertex. I would like to show just the edges and the vertex labels. If I try to set `vertex_shape='None'` I get a crash deep in matplotlib. If I try anything else I get the marker symbol printed over the label. For example
P = RootSystem(['A',3]).root_poset()
P.show(vertex_color='white')
Will show the graph with circles over the labels. If I shrink the labels, then the edges cover the labels.
If I do
P = RootSystem(['A',3]).root_poset()
P.show(vertex_color='white', vertex_shape='None')
there is a strange crash.deinstTue, 10 Jul 2018 12:11:12 -0500http://ask.sagemath.org/question/42892/Show3d has no partition optionhttp://ask.sagemath.org/question/42820/show3d-has-no-partition-option/ `graph.show(partition = Pi)` works but `graph.show3d(partition =Pi)` doesn't. Is this something that might be fixed in the future? Or is there a workaround? Bjørn Kjos-HanssenWed, 04 Jul 2018 02:19:18 -0500http://ask.sagemath.org/question/42820/Display a graphics object with multiple primativeshttp://ask.sagemath.org/question/42106/display-a-graphics-object-with-multiple-primatives/ I'm trying to show how a set of lines changes with a matrix transformation. The part i am having trouble with is:
g=Graphics()
for c in range(10):
g.add_primitive(parametric_plot(B*vector([x,c]) , (x, 0, 2*pi)))
show(g)
Because it doesn't plott the lines like i wanted but instead gives me
> 'Graphics' object has no attribute 'options'ionsmeFri, 20 Apr 2018 15:02:29 -0500http://ask.sagemath.org/question/42106/Graphics not plotted in same plot?http://ask.sagemath.org/question/41925/graphics-not-plotted-in-same-plot/I'm trying to make a sierpinsky triangle recursively, and i can generate all the triangles (via 3 line segments), however when i go to show my list, the graphics print separately. I saw on the documentation there's a graphics_array, which seems useful, but there weren't many examples and my tinkering with it was pretty much useless, especially since the "adjoin" feature is not yet implemented.
Also tried passing the graphics object "some_lines" to get filled by the function, but it doesn't seem like it accesses the reference. Code attached, maybe you can see a way I can plot all the lines within one sum of graphics, as was my initial attempt:
def draw_tri(some_lines, endpts):
some_lines+=line([endpts[0], endpts[1]], color='blue')
some_lines+=line([endpts[0], endpts[2]], color='blue')
some_lines+=line([endpts[1], endpts[2]], color='blue')
return
def get_mid(x,y):
return (x+y)/2
def recurse_SG(some_lines, n, endpts):
#graphics_sum = graphics_array([line([endpts[0], endpts[1]], color='blue')],3, 1)
if(n==1):
#graphics_sum[i]=draw_tri(endpts)
draw_tri(some_lines, endpts)
else:
recurse_SG(some_lines, n-1, [endpts[0], (get_mid(endpts[0][0], endpts[1][0]), get_mid(endpts[0][1], endpts[1][1])), (get_mid(endpts[0][0], endpts[2][0]), get_mid(endpts[0][1], endpts[2][1]))])
recurse_SG(some_lines, n-1, [endpts[1], (get_mid(endpts[1][0], endpts[0][0]), get_mid(endpts[1][1], endpts[0][1])), (get_mid(endpts[1][0], endpts[2][0]), get_mid(endpts[1][1], endpts[2][1]))])
recurse_SG(some_lines, n-1, [endpts[2], (get_mid(endpts[2][0], endpts[0][0]), get_mid(endpts[2][1], endpts[0][1])), (get_mid(endpts[2][0], endpts[1][0]), get_mid(endpts[2][1], endpts[1][1]))])
show(some_lines, axes=false)Luther13Sun, 08 Apr 2018 20:08:27 -0500http://ask.sagemath.org/question/41925/MatrixPlots with cell entrieshttp://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 11:19:50 -0600http://ask.sagemath.org/question/41234/Plotting in Sagehttp://ask.sagemath.org/question/41250/plotting-in-sage/I have some numbers in two separate arrays, and I want to plot them in such a way that the end result looks more or less like this:
![image description](/upfiles/15194978051374454.png)
Currently, I have a code that looks like this:
res_blue = [...] # data for the blue circles (removed for brevity)
res_red = [...] # data for the red crosses (removed for brevity)
list_plot(res_red, color='red')
But, instead the above code generates only plot with red dots. How can I combine the two arrays in the same plot, choose their color and the shape to be put in the plot?ninhoSat, 24 Feb 2018 12:46:39 -0600http://ask.sagemath.org/question/41250/Plot/Show Png/jpg in sagemath worksheethttp://ask.sagemath.org/question/40501/plotshow-pngjpg-in-sagemath-worksheet/Hello every one, I am testing sagemath for course creation. What is the fastest way to embeed png pictures and diplay them? Something like this: https://paper.dropbox.com/doc/Ubung-Lagebeziehung-Gerade-Gerade-NiPkMCucw7FeDxj15u6aZ?_tk=share_copylink thethaSat, 06 Jan 2018 09:44:00 -0600http://ask.sagemath.org/question/40501/How can i sketch the graph in sage?http://ask.sagemath.org/question/39894/how-can-i-sketch-the-graph-in-sage/ I can't add a picture but i can be described we want to sketch coordinate system in sage and we want to combine with emoji it looks like smiling face eyes should be circle mouth should be triangle who can help to us?selinkirisFri, 01 Dec 2017 10:48:47 -0600http://ask.sagemath.org/question/39894/Can I import a graphic and add to it?http://ask.sagemath.org/question/39285/can-i-import-a-graphic-and-add-to-it/One of my collaborators has made an image of some regions, and now my job is to superimpose a plot on it. So I would like to do something like the following:
pic = load('pic.png')
pts = list_plot(points)
fig = pic + pts
fig.show()
However, I get the error:
IOError: [Errno 2] No such file or directory:
'pic.png.sobj'
Is there a way to get around this, or perhaps convert my png to a sobj? (The path to the file is correct.)diana.davisThu, 26 Oct 2017 14:05:01 -0500http://ask.sagemath.org/question/39285/Sage for win 10 graphics brokenhttp://ask.sagemath.org/question/39207/sage-for-win-10-graphics-broken/I installed Sage 8 native winstall into windows 10, and all graphics plots just give me the broken graphics icon. It works with Sage for Ubuntu on the same windows so it's not my graphics system, IMHO.
Okay, the problem seems to be with Jupyter. If I start the shell from Windows instead, then Sage, then the notebook() for sagenb, the graphics work fine and are very fast. That starts a bash shell, though. Oddly, I have Ubuntu for Windows, ran Sage from that bash shell and it's still slower than the sagenb from the bash shell installed by the windows install. So I guess I'll just run that.cybervigilanteWed, 18 Oct 2017 22:03:02 -0500http://ask.sagemath.org/question/39207/how to plot a circle (without circle())http://ask.sagemath.org/question/38889/how-to-plot-a-circle-without-circle/ Hello,
I know you can plot a circle with circle(x,y,radius), but how do you do it with plot()?germacWed, 20 Sep 2017 15:43:54 -0500http://ask.sagemath.org/question/38889/How to generate graphs random geometric shapes?http://ask.sagemath.org/question/38484/how-to-generate-graphs-random-geometric-shapes/ I would like to create practice problems, rather than reusing old exam questions, to help my students practice solving geometric problems. I would like to use sagetex to produce random variations similar the questions I have listed below. I would supply examples of the pictures, but I do not have enough points to post pictures.
I am wish to be able to make one worksheet where each time it is printed, the values would be randomly assigned and graph would be produced. I know how to assign a random integer value to a variable; however, how to produce the graphs I have no understanding of how to achieve that. Thus for each of the example problems how to make the graph and how to assign the random variability to that graph.
**Example questions**
*The diagram below shows a child’s toy which is made up of a circular hoop, centre O, radius 7 cm. The hoop is suspended in a horizontal plane by three equal strings XA, XB, and XC. Each string is of length 25 cm. The points A, B and C are equally spaced round the circumference of the hoop and X is vertically above the point O.*
- Calculate the length of XO.
- Find the angle, in degrees, between any string and the horizontal plane.
- Write down the size of angle AOB
- Calculate the length of AB.
- Find the angle between strings XA and XB.
*ABCDV is a solid glass pyramid. The base of the pyramid is a square of side 3.2 cm. The vertical height is 2.8 cm. The vertex V is directly above the centre O of the base.*
- Calculate the volume of the pyramid
- The glass weighs 9.3 grams per cm^3. Calculate the weight of the pyramid.
- Show that the length of the sloping edge VC of the pyramid is 3.6 cm
- Calculate the angle at the vertex, BVC
- Calculate the total surface are of the pyramid.
LaoshiSun, 06 Aug 2017 03:20:11 -0500http://ask.sagemath.org/question/38484/Transparency option in streamline plothttp://ask.sagemath.org/question/37728/transparency-option-in-streamline-plot/In most graphics functions it's possible to set the transparency of the plot with the `alpha` option. In a streamline plot, e.g. take
sage: var('x, y')
sage: streamline_plot((y, -x**2 * y - x + y), (x, -3, 3), (y, -3, 3), density=1.4, color='black')
it doesn't work:
sage: var('x, y')
sage: streamline_plot((y, -x**2 * y - x + y), (x, -3, 3), (y, -3, 3), density=1.4, color='black', alpha=0.5)
...
WARNING: Ignoring option 'alpha'=0.500000000000000
...
Is there a workaround for this?
mforetsMon, 29 May 2017 08:20:26 -0500http://ask.sagemath.org/question/37728/Does there exist a GUI web-app that allows for edge contractions and vertex splits?http://ask.sagemath.org/question/35825/does-there-exist-a-gui-web-app-that-allows-for-edge-contractions-and-vertex-splits/I am interested in creating a web-app that allows for graph creation, edge contraction, vertex splits, and then exports to sage.
If anyone knows of something like this already developed please let me know, otherwise any suggestions on how to begin?
ThanksfieldofnodesWed, 30 Nov 2016 11:29:51 -0600http://ask.sagemath.org/question/35825/Drawing Auslander-Reiten quivers with sage possible?http://ask.sagemath.org/question/35638/drawing-auslander-reiten-quivers-with-sage-possible/Hi,
I'd like to draw an Auslander-Reiten quiver with sage. I tried to do this by viewing the Auslander-Reiten quiver as a digraph, but, unfortunately, I was not able to find out how to let sage draw both dashed and solid arrows in one digraph.
Is this possible? If not, is there another way to let sage draw Auslander-Reiten quivers?
Any help would be appreciated.
Edit:
I used the following code:
sage: H=DiGraph()
sage: H.add_edges([(2,1),(2,4),(10,4),(1,3),(4,3),(4,11),(11,6),(3,6),(3,5),(5,7),(6,7),(6,12)])
sage: H.add_edges([(7,8),(7,9),(12,9)])
After having typed
sage: H.show()
a few times I got the following output:
![pic1](/upfiles/1479480509763302.png)
Now, I'd like to draw dahed arrows indicating the Auslander-Reiten translates (e.g. a dashed arrow from 3 to 2).BernFri, 18 Nov 2016 07:49:43 -0600http://ask.sagemath.org/question/35638/Is it possible to embed a plot (or png) within another plot?http://ask.sagemath.org/question/34998/is-it-possible-to-embed-a-plot-or-png-within-another-plot/I have looked at the documentation for 2d plots without any success. I would like to know if it is possible to embed a plot within a plot.
I currently have a set of polygons and I would like to have plots of graphs embedded into each region. Something resembling the attached [image](/upfiles/14752402076305906.png).
Is it possible to achieve this using sagemath's plotting interface?
Thanks!fidbcFri, 30 Sep 2016 07:58:10 -0500http://ask.sagemath.org/question/34998/How to see graph directly after plot() via virtualbox?http://ask.sagemath.org/question/33845/how-to-see-graph-directly-after-plot-via-virtualbox/My laptop is windows7, so I use virtualbox as instructed on the Wiki. However, when I try the plot(), the sage always tell me that "launched png viewer for Graphics object consisting of XX primitives", and so far the only way I can see the image is to save the .png graph somewhere, which is inconvenient. I've seen on Mac that the graph directly popped out after plotting, so is there anyway to let virtualbox to do so?yshuidieSat, 18 Jun 2016 03:07:47 -0500http://ask.sagemath.org/question/33845/Graphics array formattinghttp://ask.sagemath.org/question/33562/graphics-array-formatting/ I'm computing a number of plots (actually collections of 2d polygons) of roughly square aspect ratio, and would like to display them in a reasonable way:
* use two columns
* preserve order
* title each of them
* adjust the size to fill the width of my notebook, disregarding the height
First I displayed each graphics as it arrived, or combined bunches of them into `graphics_array` in order to show them. But my sage notebook (the classical one, not the IPython flavor) failed to preserve order in that case. So I feel that I have to build one big `graphics_array`.
But I've got trouble adjusting its width without specifying its height, and I don't know a suitable height up front. Most of the times if I specify one of the sizes too large, I end up with lots of empty space in one of the directions.
Furthermore, I didn't manage to title the individual graphics, since a `title` attribute to the `polygon2d` call remains without effect, while a `title` attribute to the `show` affects the whole plot and all the nested plots. Constructing an empty `Graphics(title="foo")` doesn't seem to work.
This is on sage 6.10.beta4, so things might have improved since then. If so, I haven't yet found the appropriate locations in the online documentation indicating how this changed.
If you want to try this out: I wanted to format the output of [this code](https://gist.github.com/gagern/e9606b3f12d53ff92c4541e1e7b51d6d) but using two columns and a varying number of rows for each *n*.MvGThu, 26 May 2016 18:41:11 -0500http://ask.sagemath.org/question/33562/Drawing all paths from (0, 0) to (n, n) moving one unit right or uphttp://ask.sagemath.org/question/33201/drawing-all-paths-from-0-0-to-n-n-moving-one-unit-right-or-up/This question is just the same as [this one](http://mathematica.stackexchange.com/questions/112395/how-to-draw-all-paths-from-1-1-to-n-n-by-move-1-0-or-0-1) made for Mathematica. I saw it and I was trying to reproduce it in Sage just for fun, but it's getting longer than I like and I would love to know your approach in Sage. I think it's a great way to learn. This is half of my try:
n=3
A=sum(line([(j, i), (n, i)]) for j in range(n+1) for i in range(n+1))
B=sum(line([(i, j), (i, n)]) for j in range(n+1) for i in range(n+1))
G = Graphics()
G += A + B
G.show(figsize=[4,4], axes=False)
result = []
combinations = [bin(i)[2:] for i in range(1, int('111111', 2))]
for num in combinations:
valid = ''.join(['0']*(6-len(num))) + num
zeros = valid.count('0')
ones = valid.count('1')
if zeros == 3 and ones == 3:
result.append(str(valid))
#At this point all the paths are stored in the variable 'results' in binary form.
#For example '010101' means right, left, right, left, right, left
paths = [[]]
for element in result:
path = []
for index, direction in enumerate(list(element)):
if direction == '0':
path.append((index, index - 1))
else:
path.append((index - 1, index))
paths.append(path)
At this point the list of list called paths is not well constructed. I realized I would have to put some `if` statements to make it work but I'm losing motivation in my solution because it's getting ugly and I don't think is very efficient.
How would you do it?
TARSFri, 22 Apr 2016 22:08:30 -0500http://ask.sagemath.org/question/33201/Insert image into Graphics objecthttp://ask.sagemath.org/question/32417/insert-image-into-graphics-object/ Is it possible to insert an image (let's say, a PNG file) into a Graphics object containing some plots?
I need to create a raster inset into a figure with the list_plot'ted curves.v_2eTue, 02 Feb 2016 06:37:32 -0600http://ask.sagemath.org/question/32417/How to make pygraphviz and sage compatible?http://ask.sagemath.org/question/31070/how-to-make-pygraphviz-and-sage-compatible/ Hi,
I would like sage to help me when I am working with (un)directed graphs and quivers, and so on. After having played around with various possibilities, I would like to convert some stuff into a string and then let sage print something like a .ps - file that contains an image from dot (or something similar to this).
> Unfortunately, I came across the following issue(s) and have no idea what to do now. With the sage version I installed, there is python 2.x as a delivered package. But it seems that sage complains about python3, what doesn't make sense to me.
Could you help me understand and solve the following:
boehmler@boehmler-X55A:~/Schreibtisch/bb/sage-6.9-x86_64-Linux$ ./sage
┌────────────────────────────────────────────────────────────────────┐
│ SageMath Version 6.9, Release Date: 2015-10-10 │
│ Type "notebook()" for the browser-based notebook interface. │
│ Type "help()" for help. │
└────────────────────────────────────────────────────────────────────┘
sage: import networkx as nx
sage: import matplotlib.pyplot as plt
sage: import matplotlib.image as mpimg
sage: from cStringIO import StringIO
sage: g = nx.dodecahedral_graph()
sage: d = nx.to_pydot(g)
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-6-0d33c400a5cf> in <module>()
----> 1 d = nx.to_pydot(g)
AttributeError: 'module' object has no attribute 'to_pydot'
sage: d = nx.to_agraph(g)
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-7-d9254026fb59> in <module>()
----> 1 d = nx.to_agraph(g)
/home/boehmler/Schreibtisch/bb/sage-6.9-x86_64-Linux/local/lib/python/networkx/drawing/nx_agraph.pyc in
to_agraph(N)
132 raise ImportError('requires pygraphviz ',
133 'http://networkx.lanl.gov/pygraphviz ',
--> 134 '(not available for Python3)')
135 directed=N.is_directed()
136 strict=N.number_of_selfloops()==0 and not N.is_multigraph()
ImportError: ('requires pygraphviz ', 'http://networkx.lanl.gov/pygraphviz ', '(not available for Python3)')
sage:
Exiting Sage (CPU time 0m3.33s, Wall time 56m28.80s).
After typing
boehmler@boehmler-X55A:~/Schreibtisch/bb/sage-6.9-x86_64-Linux$ sudo -H pip install pygraphviz
I get the message
Wall -Wstrict-prototypes -fPIC -I/usr/include/graphviz -I/usr/include/python2.7 -c pygraphviz/graphviz_wrap.c -o build/temp.linux-x86_64-2.7/pygraphviz/graphviz_wrap.o
pygraphviz/graphviz_wrap.c:130:21: fatal error: Python.h: Datei oder Verzeichnis nicht gefunden
# include <Python.h>
^
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
----------------------------------------
Command "/usr/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip-build-6yZh3l/pygraphviz/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-a6o8Fg-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-6yZh3l/pygraphviz
in the end. I would be grateful for any hints how to solve / fix this.
Thanks for the help!
BernWed, 25 Nov 2015 20:42:50 -0600http://ask.sagemath.org/question/31070/How to draw special trees from a list consisting of tuples with Sage?http://ask.sagemath.org/question/30673/how-to-draw-special-trees-from-a-list-consisting-of-tuples-with-sage/ I have the following problem:
Imagine, we have tuples (1,1), (1,2), ... , (1,n), (2,1), (2,2), (2,n), (3,1), ... , (k,n) in a list `L`.
To every tuple `(i,j)` I have associated a list <code>L<sub>{ij}</sub>=[...]</code>. The entries of <code>L<sub>{ij}</sub></code> are special other tuples from `L`, which we call "compatible with the tuple `(i,j)`". So, in general, all the lists <code>L<sub>{ij}</sub></code> are different from one another.
I would like the PC to draw trees in the following manner:
In the first level, there is one tuple T. This was manually chosen from the list `L`.
In the second level, there are all the tuples <code>T<sub>1</sub>, ... , T<sub>r</sub></code>, which are compatible with T. Each of them shall be connected with `T` by a single line.
In the third level, for each tuple <code>T<sub>s</sub></code> of the second line, there are drawn all the tuples that are compatible with <code>T<sub>s</sub></code> **and** at the same time already appeared one level higher (here: in level 2). Call the tuples of this level <code>T<sub>1<sub>1</sub></sub>, ... , T<sub>1<sub>m</sub></sub>, T<sub>2<sub>1</sub></sub>, ... T<sub>2<sub>p</sub></sub>, ...</code>. Each of the <code>T<sub>1<sub>1</sub></sub>, ... , T<sub>1<sub>m</sub></sub></code> shall be connected with <code>T<sub>1</sub></code> by a single line. Each of the <code>T<sub>2<sub>1</sub></sub>, ... , T<sub>2<sub>p</sub></sub></code> shall be connected with <code>T<sub>2</sub></code> by a single line, and so on.
Iterate this, until the process stops (is finished) and you have drawn a tree.
The arrows of the tree are just edges and the points are the tuples, that should be numbered by `(1,1), ... , (k,n)`. Note that not every entry of `L` has to appear in the resulting tree, since the lists <code>L<sub>{ij}</sub></code> need not be a partition of `L`.
Here is a small example:
Let L=[(1,1), (1,2), (1,3), (2,1), (2,2), (2,3)].
Let L_{11}=[(2,2), (2,3), (2,1)].
Let L_{12}=[(1,3), (2,1)].
Let L_{13}=[(1,2)].
Let L_{21}=[(1,1), (1,2),(2,2)].
Let L_{22}=[(1,1), (2,1)].
Let L_{23}=[(1,1)].
This gives the following tree for `(1,1)`:
(1,1)
--------------|--------------
| | |
(2,1) (2,2) (2,3)
| |
| |
(2,2) (2,1)
Not only the tree, but also its "longest" branches (i.e. these, that can no more be extended by the procedure above...in the above example, these are `(1,1)-(2,1)-(2,2)` and `(1,1)-(2,2)-(2,1)` and `(1,1)-(2,3)`) should be returned (there are no repetitions allowed in the branches).
Now, my question is:
> What's the best possibility to solve problems of this kind in a fast way with Sage?
Thanks for the help!BernThu, 12 Nov 2015 10:31:27 -0600http://ask.sagemath.org/question/30673/