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.Tue, 04 May 2021 21:17:37 +0200Assign RGB values to points on implicit_plot3d graphhttps://ask.sagemath.org/question/56955/assign-rgb-values-to-points-on-implicit_plot3d-graph/Is there a way to assign an explicit RGB color to each point satisfying an equation of the form f(x,y,z)=c? For instance, I would like it if the command
```
implicit_plot3d(x+y+z==1,(x,0,1),(y,0,1),(z,0,1),color=(x,y,z))
```
colored the standard 2-simplex in R^3 according to the associated RGB values, but it doesn't. I'm aware that one can use colormaps and functions R^3 -> R to color the output of implicit_plot3d but I would like to use a function R^3 -> [0,1]^3 to do the coloring.kyle oTue, 04 May 2021 21:17:37 +0200https://ask.sagemath.org/question/56955/How change latex background text color in jupyter?https://ask.sagemath.org/question/54357/how-change-latex-background-text-color-in-jupyter/Expression Math( r"\color{green}{sample}") displays green text in latex in jupyter workbook. What is the directive to change the background color of the text? The directives \textcolor, \colorbox do not work.robSun, 22 Nov 2020 17:19:41 +0100https://ask.sagemath.org/question/54357/How to change the unreadable dark blue colour in the SageMath command line window under Windows-10?https://ask.sagemath.org/question/47136/how-to-change-the-unreadable-dark-blue-colour-in-the-sagemath-command-line-window-under-windows-10/ I have just installed SageMath 8.7 on my Windows-10 laptop and want to learn it. The font colour of the prompt and of the typed numbers is dark blue on the black background, totally unreadable. Google search delivers tons of such complaints about bash/pythin/mintty/cygwin command lines. All suggest to edit some configuration files, which are hardly possible to locate in SageMath, neither in the SageMath installation directory, nor in my user home directory. There is a file ".sage\profile_default\ipython_config.py" in my Windows home, containing the line
c.TerminalInteractiveShell.colors = 'Linux'
Changing this line has no effect.SevasFri, 12 Jul 2019 12:59:10 +0200https://ask.sagemath.org/question/47136/Pil image colors not requestedhttps://ask.sagemath.org/question/52038/pil-image-colors-not-requested/ Hi
Ubuntu 18.04 SageMath 9.1 Jupyter notebook
does anyone know why the colors are not the ones i asked for? :
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
import numpy as np
from matplotlib.pyplot import figure
figS=2
figure(num=None, figsize=(figS, 1*figS), dpi=150, facecolor='w', edgecolor='k')
from PIL import Image, ImageColor
imSize=(10,10) # Image size= 10x10 pixels
imageModeL=["L", "LA", "P", "PA"]
iMmode=imageModeL[0]
im = Image.new(iMmode, imSize)
for i in range(imSize[0]) :
for j in range(imSize[1]) :
im.putpixel((i,j), ImageColor.getcolor("white",iMmode))
im.putpixel((0,0), ImageColor.getcolor('red',iMmode))
im.putpixel((1,0), ImageColor.getcolor('blue', iMmode))
im.putpixel((3,3), ImageColor.getcolor('pink', iMmode))
im.putpixel( (2, 2), ImageColor.getcolor('green', iMmode))
imgPath="/home/ortollj/Downloads/SageMath/IPYNB/"
im.save(imgPath+'tenXtenPixels.png')
img = mpimg.imread(imgPath+"tenXtenPixels.png")
imgplot = plt.imshow(img)
![image description](/upfiles/15923008595368105.png)
ortolljTue, 16 Jun 2020 11:48:43 +0200https://ask.sagemath.org/question/52038/Discontinuous surface color by z-levelhttps://ask.sagemath.org/question/46541/discontinuous-surface-color-by-z-level/Hi there,
I want to plot a surface $z=f(x,y)$ together with the level curves (side by side). I know how to doi it when $f$ is continuous, or even bounded, but I run in trouble for uglier functions. Here are two examples (in CoCalC : a few things need to be adapted to use Jupyter) : the first works
var('x,y,s,t')
h(x,y)= x*y^2/(x^2+y^4)
cm = colormaps.Blues
def c(x,y):
return 0.6+x*y^2/(x^2+y^4+0.005)# Colorier ceci pose des problèmes, à cause de la singularité.
S=plot3d(h,(x,-1,1),(y,-1,1),color = (c,cm), opacity=1, mesh=1)
show(S)
C=contour_plot(h, (x,-1, 1), (y,-1, 1),cmap='Blues',linestyles='solid', colorbar=True)
show(C,figsize=4)
While the second, below, does not work as I would like to
h(x,y)= y/(x^2+y^2)
cm = colormaps.Spectral
def c(x,y):
return float(y/(x^2 + y^2+0.005))# Colorier ceci pose des problèmes, à cause de la singularité.
S=plot3d(h,(x,-1,1),(y,-1,1),color = (c,cm), opacity=1, mesh=1)
show(S, frame_aspect_ratio=[20,20,1])
C=contour_plot(h,(x,-1.5,1.5),(y,-1.5,1.5), cmap = "Spectral",
contours = [-2,-1, -0.5,-0.25,0,0.25,0.5,1,2], colorbar = True,
axes = True,
labels = True, label_colors='black',
label_inline=True, label_fontsize=8,
gridlines = True, axes_labels=['$x$','$y$'])
show(C,figsize=8)
I tried a few things, among other, what can be found https://ask.sagemath.org/question/7581/use-a-colormap-for-implicit_plot3d/[here (old post)](https://ask.sagemath.org/question/7581/use-a-colormap-for-implicit_plot3d/), but the discontinuity seems to cause some problems.
Suggestions?JCThu, 16 May 2019 03:12:51 +0200https://ask.sagemath.org/question/46541/How to put background color behind animationhttps://ask.sagemath.org/question/46531/how-to-put-background-color-behind-animation/So I read some of the questions and answers on this site but none of them got me a clear answer. I'm making an animation showing the group law of an elliptic curve. Anyways, I want it to look perfect so I simply need a positive colored background; I was thinking light green (maybe use hue). (Besides, where can I find a table that lists all the values of the hue colors without having to compute them myself?) My animation consists of a few frames played very slowly. My first frame is simply the curve. I had the idea to put it all in a big colored polygon to achieve the background. I could not find simple background color options for plots. This is my poor attempt:
E = EllipticCurve(y^2==x^3+4*x^2-5*x+2);
L = [(-6,-20),(-6,20),(6,20),(6,-20)];
frames = plot(E,xmin=-6,xmax=6,ymin=-20,ymax=20,color='red',thickness=3);
frames += polygon(L,color=hue(0.40));
The problem is now that my plot is completely deformed... Of course, this looks very unpleasent. Anyone got an idea to deform the polygon such that the plot of this elliptic curve is nicely like it looks standard, as evaluating ` plot(E,xmin=-6,xmax=6,ymin=-20,ymax=20,color='red',thickness=3)`? Oh, and also the color should be a bit more transparent. Thanks for the time.AlgebearWed, 15 May 2019 18:47:35 +0200https://ask.sagemath.org/question/46531/Color plots on surface of spherehttps://ask.sagemath.org/question/9753/color-plots-on-surface-of-sphere/I would like to use Sage to draw colormap plots of spherical functions on the surface of spheres. I want to produce something like
[this example](http://mailinglists.scilab.org/Plotting-functions-of-spherical-coordinates-on-a-sphere-td4025441.html).
Are such plots currently possible in Sage, or using optional toolkits? I would like to have a color plots of arbitrary functions f(theta,phi).
Moreover, is it possible to have contour plots of such functions as well?
OMFWed, 30 Jan 2013 12:05:04 +0100https://ask.sagemath.org/question/9753/How to change color AFTER calling "plot"?https://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 20:51:38 +0100https://ask.sagemath.org/question/45422/Fill colors with two contour plotshttps://ask.sagemath.org/question/41457/fill-colors-with-two-contour-plots/Assume I have two contour plots, of functions A and B, say, depending on x and y, with one level curve on each plot.
There are two different zones in each plot, filled with two colors, like in the following:
Gr=Graphics();
Gr += contour_plot(A,(x,0,10),(y,0,10),contours=1,cmap=['white', 'red']);
Gr += contour_plot(B,(x,0,10),(y,0,10),contours=1,cmap=['yellow', 'blue']);
show(Gr);
The problem is that the resulting picture only shows the filling colors of the second plot.
How do I get a picture with each zone (from both plots) in a different color ? some kind of transparency ?
Sorry if my question is trivial,
Thanks !user111Fri, 09 Mar 2018 22:30:28 +0100https://ask.sagemath.org/question/41457/How to color a 3d plot by z-level?https://ask.sagemath.org/question/8964/how-to-color-a-3d-plot-by-z-level/I'd like to color a 3d plot based on z-level. I think this is easy to do in Maple or Mathematica, but I've been searching the web for help on doing this in Sage and can't find anything to help with plot3d or implicit_plot3d.
Here's the implicit_plot3d I'm using.
var('x,y,z')
implicit_plot3d(x^2-y^2*z == 0,(x,-4,4),(y,-4,4),(z,-4,4)).show(mesh=True)
Also, are there color maps in Sage that produce plots with colors and lighting similar to the default in Mathematica?
calc314Wed, 09 May 2012 23:27:40 +0200https://ask.sagemath.org/question/8964/Updating graph plothttps://ask.sagemath.org/question/36342/updating-graph-plot/I wish to visualize a algorithm running on a graph. How can I update the plot of a graph after for example deleting a vertex or to change color of a vertex without generating another plot window?AckslThu, 19 Jan 2017 09:29:05 +0100https://ask.sagemath.org/question/36342/plot point color changehttps://ask.sagemath.org/question/36295/plot-point-color-change/How do change the plot point color so that I can tell the difference between my three different equations?
Here is what I have so far:
S = []
I = []
R = []
S.append(100000)
I.append(100)
R.append(0)
beta = 100
gamma = .4
lamda = 5e-006
mu = .001
i = 0
while(i<100):
R.append(R[i] + (-mu * R[i] + gamma * I[i]))
I.append(I[i] + (-mu * I[i] + lamda * S[i] * I[i] - gamma * I[i]))
S.append(S[i] + (beta - mu * S[i] - lamda * S[i] * I[i]))
i = i+1
N=range(1,100)
A = S
AN=zip(N,A)
B = I
BN=zip(N,B)
C = R
RN = zip(N,R)
plot(point(BN), legend_label = 'S(t)', color = 'green')kaylavb23Sun, 15 Jan 2017 03:44:20 +0100https://ask.sagemath.org/question/36295/Coloring surfaces in plot3dhttps://ask.sagemath.org/question/9068/coloring-surfaces-in-plot3d/I'm really new with sage, and what I would like is to color a graph from plot3d according to some function (specifically, I would want the hue to vary with the magnitude of the gradient). Is there some way of doing this easily?hihoWed, 12 Sep 2012 18:16:12 +0200https://ask.sagemath.org/question/9068/sage terminal colorshttps://ask.sagemath.org/question/10060/sage-terminal-colors/I just upgraded from sage version 4.8 to version 5.8. I was pleasantly surprised to see colouring of the text similar to ipython does. However, sage seems to be defaulting to colours geared towards white background and black text. I have a black background and white text. The default colour scheme is very hard to read and I can't figure out how to change it. I did find this web page (http://mvngu.wordpress.com/2009/05/21/add-colour-to-your-sage-session/) but following the instructions in it does not work and my sage colour scheme is always that of figure 3 on the link, but my system terminal settings have a black background and white text. Although I would prefer the right colour scheme, the old pure black and white would be better than what I have now. How can I change the sage terminal colours to something more readable? I don't want to change my default system terminal settings.
I can type "%colors Linux" once I launch sage and it does then give me the colour scheme that I want, but I can't get the scheme to persist from session to session.
kjlvcxzoiperwqWed, 24 Apr 2013 14:17:36 +0200https://ask.sagemath.org/question/10060/how do I change the color of the tickshttps://ask.sagemath.org/question/33261/how-do-i-change-the-color-of-the-ticks/ I have this [sage cell](https://sagecell.sagemath.org/?z=eJxFjsFqwzAQRO-F_oNQLhKsje1bKTr7B3oMNkq8agWqZVYbW87XRw6B3GaG2beTYYc7MNxgNWK1pGR-J1J_f36cgmXM9YpXjjROGPy_Z6Sk5Pkc7PwbUEgQxdDLHEdOFYw2X1UeumofuhL1ZgmRxxfHeQyTcvXknVMaROlXbQNtc-j9rblQ02IJZzY_dEMQ4olZop85mbYDcY0hkpEXittclti0lBcjWfbRtMeYvrYZ0_jsKdVAQesjT39xU71-ACxSUEE=&lang=sage)
`x,y,z,t,u,v= var("x,y,z,t,u,v");
f(x,y)=9-x^2-y^2;
G=plot_vector_field(f.diff(), (x,-10,10), (y,-10,10), transparent=True, plot_points=12, color="brown", aspect_ratio=1);
G.axes_color((0,0,1));
show(G)`
but I would like the tick color to match the blue axes color.
all help is appreciated.
userXSat, 30 Apr 2016 01:08:19 +0200https://ask.sagemath.org/question/33261/Plotting a 2d functionhttps://ask.sagemath.org/question/25122/plotting-a-2d-function/This should be easy, I want to make a nice colour plot of a 2d function where colour denotes the function value.
I can do
> y=var('y')
> f=y^2
> plot(f)
and I get a nice plot.
If I try
> y=var('y')
> f=y^2+x^2
> plot(f)
Then sage tells me it can't find the variable y. Which is ridiculous, since y is in the same place as when I tried to plot a 1d function of y. Anyway, I tried googling to find a function within sage to achieve this (without resorting to excessive matplotlib syntax) and had no success so thought I'd ask a question here. Intuitively, the second case is hardly more complicated than the former so there should be a simple function that can realize this for me.
Many thanks!DarwinThu, 04 Dec 2014 17:53:03 +0100https://ask.sagemath.org/question/25122/How to make a custom divergent colormap?https://ask.sagemath.org/question/24180/how-to-make-a-custom-divergent-colormap/How can I make a custom diverging colormap in Sage?
What I want is the same than the reverse `seismic` diverging colormap ([Diverging Colormaps](http://matplotlib.org/examples/color/colormaps_reference.html)) but the blue value should be less intense (e. g. conflower blue [Hex color code: #6495ED]).
In the sage source code I found the following link [Diverging Colormaps](http://www.sandia.gov/~kmorel/documents/ColorMaps/), which explains the divergent colormaps and has a python class in the attachments. But still I have no clue to make such a diverging colormap.
I have also tried to make it with a LinearSegementedColormap:
from pylab import *
startcolor = '#FF0000'
midcolor = '#FFFFFF'
endcolor = '#0030CC'
own_cmap1 = matplotlib.colors.LinearSegmentedColormap.from_list( 'own2', [startcolor, midcolor, endcolor] )
matrix_plot( matrix( [ [1,3,5,1], [2,4,5,6], [1,-3,5,7] ] ), cmap = own_cmap1, colorbar = True )
but the result is absolutely not what I want, because it goes too fast from red into pink.
balduinThu, 18 Sep 2014 14:49:34 +0200https://ask.sagemath.org/question/24180/Custom color map for matrix plot?https://ask.sagemath.org/question/24051/custom-color-map-for-matrix-plot/I need colormap which has for a fixed value x the color white and all values above x are colorized from white do blue and all values below x are colorized from white to red.
The first question is, is this possible?
And my second question how can I do that?balduinMon, 08 Sep 2014 17:27:10 +0200https://ask.sagemath.org/question/24051/Controling the color of a parametric surface.https://ask.sagemath.org/question/11354/controling-the-color-of-a-parametric-surface/I would like to represent a complex valued function on a parametric surface. I know that the complex_plot function can represent a complex function using colors. Is there a way of using it to color parametric surfaces? In other words, can I define the colors of the points of a parametric surface in terms of the two parameters in a natural and easy way?
RaulTue, 29 Apr 2014 22:48:30 +0200https://ask.sagemath.org/question/11354/How can I Change the background color of a plot.https://ask.sagemath.org/question/11361/how-can-i-change-the-background-color-of-a-plot/I want to create some plots using sage to then save them in my computer. I don't want the background to be white (or transparent). Is there a way of specifying the background of a plot inside sage?
(I'm looking for an option of the form:
sage: t=var('t')
sage: p=parametric_plot((t,2*t), (t, -5, 5))
sage: p.show(background=(.1,.2,.3))
or something like that.)RaulFri, 25 Apr 2014 14:21:00 +0200https://ask.sagemath.org/question/11361/different color on backside of surfacehttps://ask.sagemath.org/question/10290/different-color-on-backside-of-surface/Hey,
I want to animate a 3D plot. Therefore I generate tachyon rendered implicit plots which I then send to ffmpeg. This works quite well. The only disadvantege, is that it's during the video hard to distinguish which side of the surface one sees. Therefore I want to change the color of the backside or at least increase the shadow.
I already tried some stuff with the tachyon raytracer building a scene. But this does not work for implicit plots. The solution given [here](http://ask.sagemath.org/question/20/the-tachyon-object-used-for-rendering-plots) seems not to be very usefull in this context.
Is there perhaps a simply trick, which does the job?
ThorstenWed, 26 Jun 2013 17:38:03 +0200https://ask.sagemath.org/question/10290/Can I show equations in black rather than blue?https://ask.sagemath.org/question/9376/can-i-show-equations-in-black-rather-than-blue/When I `show()` or `view()` an equation, it displays in blue. But when I refer to the same equation with a `<sage>` tag inside an html environment, it displays in black. Can I change the default color to black? I've tried passing various color options to `show()` but it doesn't seem to work.PatrickSurryThu, 06 Dec 2012 15:14:53 +0100https://ask.sagemath.org/question/9376/highlighting the code in notebookhttps://ask.sagemath.org/question/7871/highlighting-the-code-in-notebook/I wonder if there is any way to highlight the code (things like "def" "for") in the notebook.
I have found some informations about the css fileused by notebook but maybe someone could describe me the way if there is one.
Thanks.stanislavSat, 15 Jan 2011 11:12:42 +0100https://ask.sagemath.org/question/7871/