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, 30 Apr 2022 01:37:24 +0200I can't generate graphs."The kernel appears to have died"https://ask.sagemath.org/question/62218/i-cant-generate-graphsthe-kernel-appears-to-have-died/ I have installed Sage on my Windows 10 machine
SageMath version 9.3, Release Date: 2021-05-09
Using Python 3.7.10.
I tried to plot something simple like
plot(x^2)
I received this message in Jupyter Notebook:
Kernel Restarting.
The kernel appears to have died. It will restart automatically.
And this message SageMath 9.3 Notebook Server
Unhandled SIGSEGV: A segmentation fault occurred.
This probably occurred because a *compiled* module has a bug
in it and is not properly wrapped with sig_on(), sig_off().
Python will now terminate.
------------------------------------------------------------------------
[I 18:19:09.280 NotebookApp] KernelRestarter: restarting kernel (1/5), keep random ports
WARNING:root:kernel 7bc88a4e-b9a1-488d-bbe6-fa359a6758ab restarted
I have the same problem using matplotlib , for example:
import matplotlib.pyplot as plt
import numpy as np
t = np.linspace(0,1,10)
plt.plot(t,t**2)
plt.show()
jvg21352Sat, 30 Apr 2022 01:37:24 +0200https://ask.sagemath.org/question/62218/Plot points of different sizeshttps://ask.sagemath.org/question/57173/plot-points-of-different-sizes/Say I have a map M:
[0,1] -> .3
[1,2] -> 1.1
[-3,-3] -> .6
etc.
I want to make a scatter plot where the point at P has size M[P]. How do I do this? Presumably I use the point2d object, which takes a size parameter.ant314159265Thu, 20 May 2021 00:32:57 +0200https://ask.sagemath.org/question/57173/How show vector or matrix in legend label of plot in latex?https://ask.sagemath.org/question/55304/how-show-vector-or-matrix-in-legend-label-of-plot-in-latex/We can insert latex in legend labels by surrounding the text with '$'. But it doesn't work for a vector (matrix, array), e.g.
\left[\begin{array}{r} 1 \\ 0 \end{array}\right]
Is there any way to display vector in latex in legend label?robSat, 16 Jan 2021 14:32:42 +0100https://ask.sagemath.org/question/55304/Plot ratio of Bessel functionshttps://ask.sagemath.org/question/54361/plot-ratio-of-bessel-functions/I am new to SageMath and to this page. I'm running this version:
`SageMath version 9.2, Release Date: 2020-10-24 Using Python 3.8.5.`
I tried to plot the ratio of two functions related to Bessel functions.
First I defined `f` as the first derivative of `bessel_J(1, x)`
and `g`as `x*bessel_J(1, x)`:
f(x) = bessel_J(1, x)
g = derivative(f, x)
Then I defined `h` as their ratio:
h = g / (x*f)
Then, I tried to plot `h` with:
plot(h, (x, 0, 10))
The result is an empty plot, showing only the x, y axes, and this is not correct.
Am I doing something wrong? Is it possible to plot such a function and, if yes, how?wmaddoxSun, 22 Nov 2020 23:49:14 +0100https://ask.sagemath.org/question/54361/plotting multiple functions from a for loophttps://ask.sagemath.org/question/46357/plotting-multiple-functions-from-a-for-loop/ This solution:
https://ask.sagemath.org/question/9024/plotting-multiple-functions-from-a-for-loop/#
is not working any more
The error is:
Error in lines 3-3
Traceback (most recent call last):
File "/cocalc/lib/python2.7/site-packages/smc_sagews/sage_server.py", line 1188, in execute
flags=compile_flags) in namespace, locals
File "", line 1, in <module>
File "/ext/sage/sage-8.7_1804/local/lib/python2.7/site-packages/sage/misc/decorators.py", line 492, in wrapper
return func(*args, **options)
File "/ext/sage/sage-8.7_1804/local/lib/python2.7/site-packages/sage/plot/plot.py", line 1956, in plot
G = _plot(funcs, (xmin, xmax), **kwds)
File "/ext/sage/sage-8.7_1804/local/lib/python2.7/site-packages/sage/plot/plot.py", line 2224, in _plot
legend_label=legend_label_entry, legend_color=legend_color_entry, **options_temp)
File "/ext/sage/sage-8.7_1804/local/lib/python2.7/site-packages/sage/misc/decorators.py", line 492, in wrapper
return func(*args, **options)
File "/ext/sage/sage-8.7_1804/local/lib/python2.7/site-packages/sage/plot/plot.py", line 1941, in plot
G = funcs.plot(*args, **original_opts)
TypeError: plot() takes exactly 1 argument (17 given)thethaThu, 25 Apr 2019 11:06:52 +0200https://ask.sagemath.org/question/46357/Octave-like plot function, or, how to plot sequence of points?https://ask.sagemath.org/question/47029/octave-like-plot-function-or-how-to-plot-sequence-of-points/Let's say I have the following set of points: (1, 2), (5, 8), (7, 13), (8, 10), (8.7, 9), (10, 6.3), (13, 2), (15, -1).
I would like to plot a 2D graph passing through them.
In octave, I can do the following:
octave:47> x = [1, 5, 7, 8, 8.7, 10, 13, 15]
octave:48> y = [2, 8, 13, 10, 9, 6.3, 2, -1]
octave:49> plot(x, y)
And I get this [graph](https://drive.google.com/open?id=1iE4hhpcYBGwjAvF45F_hruxKwpl3ccvV).
How can I do something similar in sage?
Hilder Vitor Lima PereiraTue, 02 Jul 2019 09:00:09 +0200https://ask.sagemath.org/question/47029/Label function automaticaly, 2d plothttps://ask.sagemath.org/question/41482/label-function-automaticaly-2d-plot/Function:
def random_between(j,k):
a=int(random()*(k-j+1))+j
return a
t = var('t')
m1=random_between(-5,5)
b1=random_between(-5,5)
y1=m1*t+b1
m2=random_between(-5,5)
b2=random_between(-5,5)
y2=m2*t+b2
m3=random_between(-5,5)
b3=random_between(-5,5)
y3=m3*t+b3
m4=random_between(-5,5)
b4=random_between(-5,5)
y4=m4*t+b4
p1=plot(y1, (t,-5,5), gridlines=True,color='red')
p2=plot(y2, (t,-5,5), gridlines=True,color='green')
p3=plot(y3, (t,-5,5), gridlines=True,color='orange')
p4=plot(y4, (t,-5,5), gridlines=True,color='pink')
p=p1+p2+p3+p4
show(p)
Well, I would like to view full grid, and auto lable functions, is this possible, i have here 3 Books, do i have to look somewhere else?thethaSun, 11 Mar 2018 01:30:44 +0100https://ask.sagemath.org/question/41482/Plotting in Sagehttps://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 19:46:39 +0100https://ask.sagemath.org/question/41250/Bar chart bar widthhttps://ask.sagemath.org/question/40923/bar-chart-bar-width/ Is there a way to set a different width for each column in the `sage.plot.bar_chart.BarChart` class?davidcorbinThu, 01 Feb 2018 18:09:07 +0100https://ask.sagemath.org/question/40923/connecting plots by lineshttps://ask.sagemath.org/question/38845/connecting-plots-by-lines/There are 2 plots in a graphics_array (e.g. sin and cos). How do I "connect" these plots with connecting lines (e.g. a dashed line at angle=pi)?Chris_Mon, 18 Sep 2017 15:21:55 +0200https://ask.sagemath.org/question/38845/How to draw x^2-3*y^2=4 2d plot ?https://ask.sagemath.org/question/37373/how-to-draw-x2-3y24-2d-plot/It shows error, when I use 'y' variable, and says it is not defined.
So only plots of the form y=f(x) are allowed. How do I overcome this limitation in plotting?
And also how are 2d plots converted to 3D. I know how to do it. But how is it possible to make a 3d plot of a curve say, sin , as it is inherently in 2 dimensions.screened00Sun, 23 Apr 2017 18:05:08 +0200https://ask.sagemath.org/question/37373/How do I plot a function undefined in some areas?https://ask.sagemath.org/question/34850/how-do-i-plot-a-function-undefined-in-some-areas/ I am trying to plot `f(x,z)` which is undefined in some areas. When I try to plot some other function, I can get it to work easily because Sage restricts the plot to the area where the function is real. E.g.:
plot3d(sqrt(1-x^2-y^2), (x,-5,5), (y,-5,5))
The border is a bit weird, but it works. I cannot get a working plot with my code, however. I also tried to wrap the function with a `try ... except` statement but I don't know what to return:
var("x y z")
def wrap(exp, a, b):
try:
return exp(x=a, z=b)
except ValueError:
return None
plot3d(lambda x,y: wrap(f, x, y), (x, -t, t), (y, -t, t)).show(aspect_ratio=1)
My function is `f` and it contains variables `x` and `z`.LazzaSun, 18 Sep 2016 22:02:42 +0200https://ask.sagemath.org/question/34850/Plot shared axishttps://ask.sagemath.org/question/33510/plot-shared-axis/I was trying to convert this into sage. Basically print function, first derivative, second derivative all sharing the x axis. Instead of scipy.misc.derivative I'd like to use sage derivative(). I have tries for hours an got several different errors. Any ideas?
d={}
with open(source) as f:
for line in f:
(key, val) = line.split()
d[str(key)] = val
print key
f = lambda t : eval(val)
x = np.arange(1,20,0.01)
first = derivative(f,x,dx=1,n=1)
second = derivative(f,x,dx=1,n=2)
fig,ax = plt.subplots(3,1,sharex=True)
#plt.suptitle("\n".join(wrap(str(key + " - \n" + val), 50)))
ax[0].plot(x,f(x))
ax[0].set_ylabel(r'$f(x)$')
ax[1].plot(x,first)
ax[1].set_ylabel(r'$f\/\prime(x)$')
ax[2].plot(x,second)
ax[2].set_ylabel(r'$f\/\prime\prime(x)$')
ax[2].set_xlabel(r'$x$')
plt.savefig()
plt.close()
The results should be something like this (i would upload my own image but I realized I cannot):
http://matplotlib.org/_images/subplots_demo_03.png
brenogilSun, 22 May 2016 15:30:01 +0200https://ask.sagemath.org/question/33510/how to user a external program to plot graphic?https://ask.sagemath.org/question/32454/how-to-user-a-external-program-to-plot-graphic/ how to user a external program to plot graphic?
ex: gnuplot, xmaxima, mgnuplot....jmarcellopereiraThu, 04 Feb 2016 20:32:43 +0100https://ask.sagemath.org/question/32454/Displaying a numpy plothttps://ask.sagemath.org/question/26122/displaying-a-numpy-plot/ import matplotlib
import numpy as np
import matplotlib.pyplot as plt
plt.figure(figsize=(6, 3))
plt.plot(x, y)
plt.show()
Why doesn't `plt.show()` display my plot? `plt.savefig('myplot.png')` works, however.
thanksGeremiaTue, 10 Mar 2015 00:44:23 +0100https://ask.sagemath.org/question/26122/swap axes in 2d plothttps://ask.sagemath.org/question/25066/swap-axes-in-2d-plot/<p>Hi guys. Just playing around with titration curves in water, which is a remarkably difficult problem to do.</p>
<p>Basically I can derive an equation for volume of base versus pH of solution, and plot it.</p>
<p>However, I'd like to swap the x and y axes.</p>
<p>Or do I have to use implicit_plot? :(</p>JoalHeagneyMon, 01 Dec 2014 06:05:59 +0100https://ask.sagemath.org/question/25066/