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, 07 Jan 2023 13:58:18 +0100plot scattered datahttps://ask.sagemath.org/question/65806/plot-scattered-data/I'm totally new and ingnorant in sage however trying to learn by doing.
Thanks to other tips that I got here, I managed to make a real progress and now struggling with something that is pretty straightforward in other environments not in sage because of the logic (that I'm still missing)
i'm putting the full example that I simplified to focus on the issue.
i;e in practice I don't have these two functions.
One has to understand that I have no contro on the structure of the data that I need to plot. it's simply two vectors u & v in R^2
#example:
f(x) = 2*sin(2*x+4)
g(x) = 3*sin(-x-4)
eq=f-g
pf = plot(f(x), (x,-pi,pi), color="red", fill=max_symbolic(f(x),g(x)),
fillcolor="lightgreen")
pg = plot(g(x), (x,-pi,pi), color="blue")
show(pf+pg)
nbi=20
endpoints = [-pi+2*pi*i/(nbi-1) for i in range(nbi)]
c=[]
for i in range(nbi-1):
try:
a=endpoints[i]
b=endpoints[i+1]
sol=eq.find_root(a,b)
c.append(n(sol,digits=3))
except RuntimeError:
rep="no sol" #sometime I need to treat that properly
yc=[f(k) for k in c]
mypoints=[[c[k],f(c[k])] for k in range(len(c))]
print(mespoints)
# problems appear from here
ph=plot(mypoints, marker="*",color="black")
show(pf+pg+ph)
Basically I just need to approx highlight the zeros of f-g (intersection points)
any help is a step further in my learning path.
thx
MmoonSat, 07 Jan 2023 13:58:18 +0100https://ask.sagemath.org/question/65806/highlighting specific regions in a plothttps://ask.sagemath.org/question/65649/highlighting-specific-regions-in-a-plot/I'm working on displayind*g the regions where a specific condition between two functions.
As an example I want to color or highlight in a way or another the areas where let's say where x/ f(x)<g(x)
f(x)=sin(2*x + 3)
g(x)=2*cos(2*x + 2)
plot([f(x),g(x)],[x,-pi,pi])
How can I approach that ?
Thx for any kind of hint.moonSun, 01 Jan 2023 15:29:08 +0100https://ask.sagemath.org/question/65649/latex code of plotshttps://ask.sagemath.org/question/65047/latex-code-of-plots/ Dear,
I'm trying to get the LaTeX code of a given plot.
While it works fine in cocalc, I'm not able to get it done in my sageMath environment.
It looks like I'm missing some libraries.
s=plot(cos(x),[x,-pi,pi])
show(s)
print(latex(s)) #checkpoint
with open("tmp/demo.tex", 'w') as f:
f.write(str(latex(s))) #ultimate target
f.close()
Here is the error generated:
ValueError: Matplotlib requires either xelatex, lualatex, or pdflatex.
Any idea ?moonThu, 24 Nov 2022 19:57:05 +0100https://ask.sagemath.org/question/65047/Difficulty with log and ploting loghttps://ask.sagemath.org/question/64727/difficulty-with-log-and-ploting-log/x >= 0
x <= 2
g(x) = ln(x)
h(x) = (x - 2 ) ^ 2
f(x) = g(x) - h(x)
print(f)
show(plot(f))
i want to combine the funtions g(x) and h(x) but instead of giving me
ln(x) - ( x - 2)^2, it gives me log(x) - (x-2)^2 for some reason
after that, when i try to plot the funtion it is zoomed in too much(it only shows me form -1 to 1) and is also incorrect
i would like to know if there is any simple ways to fix these problemsCoolAlexTue, 01 Nov 2022 19:06:14 +0100https://ask.sagemath.org/question/64727/Decouple computing data for a plot and creating the plot object?https://ask.sagemath.org/question/64715/decouple-computing-data-for-a-plot-and-creating-the-plot-object/The `plot()` function does Two Things:
1. takes your function and samples its values (somewhat intelligently) to create a list of 2D coordinate pairs
2. uses that list of coordinates to create a plot object
Is there a way to decouple these steps, i.e. separately invoke the logic of step 1 to obtain a list of 2D points and then the logic of step 2 to obtain the plot object?
The motivation for this is computing different curves of a composite plot on different cores using `@parallel`. Very unfortunately the return value of plot(), whatever it is, doesn't pickle/unpickle properly, and thus cannot be returned between threads. So if you generate separate plot objects in your `@parallel` function, all you will get at the call point will be an iterator yielding error messages. This could be avoided if I could _just_ compute the 2D data lists in threads, and "render" them to a plot in the main thread.
Is that doable?
Please be aware that I am interested in **using** `plot()`'s **actual logic** for sampling the plotted function, rather than writing my own logic that would probably be inferior.
EDIT: toy example
@parallel
def singlePlot(v):
x = var('x')
return plot((x-v)^2, xmin=-3, xmax=3)
plots = [];
for onePlot in singlePlot([0,1,2,3]):
plots.append(onePlot)
plots[0]
Outputs:
(((0,), {}), "INVALID DATA invalid load key, 'x'.")
The same `singlePlot()` function works as expected if I remove the `@parallel` decorator and call it with a single integer rather than a list.RulatirMon, 31 Oct 2022 22:31:42 +0100https://ask.sagemath.org/question/64715/Clipping a 2D plothttps://ask.sagemath.org/question/64131/clipping-a-2d-plot/Dear all,
Best is a small example:
def fC(p):
return([p[0]/(p[0]+2), (p[1]+1)/(p[0]+2)])
def actOnD(Dom, nbsteps, myz):
DomainfC = list(map(fC, Dom))
acolor = Color(0, (20+90*nbsteps)/255, 150/255)
ToPlot = polygon(Dom, color = acolor, zorder = myz)
if nbsteps > 0:
DomainfC = list(map(fC, Dom))
ToPlot += actOnD(DomainfC, nbsteps-1, myz+1)
return(ToPlot)
actOnD( [[0,0], [0,1], [1,1], [1,0]], 3, 1)
And I would like to show only the plot within a smaller square than the unit one. It seems add_conditions works for parametric plot (though I did not find the documentatin for that, only posts).
Many thanks for your lights on that!
Best, OlivierOlivier R.Wed, 21 Sep 2022 13:56:06 +0200https://ask.sagemath.org/question/64131/Plotting a periodic functionhttps://ask.sagemath.org/question/63821/plotting-a-periodic-function/I want to plot a function that is abs(x) for -1<= x <= 1 and repeats to create a sawtooth shaped function. With the code
def h(x):
while x>1:
x=x-2
return abs(x)
h(4.3)
The Sage sell server tells me the value is 0.300000000000000, which is what I want as h(4.3)=h(2.3)=h(.3)=abs(.3) However, when I tried to plot h(x) with
def h(x):
while x>1:
x=x-2
return abs(x)
plot(h(x),x,0,5)
The plot looks like abs(x), so that h(4.3) now appears to be 4.3.
What has gone wrong? How can I properly plot the h(x) I want?
**EDIT:** A points plot gives me the output I am expecting, which is different than `plot(h(x),x,0,5)`.
def h(x):
while x>1:
x=x-2
return abs(x)
points([(x, h(x)) for x in srange(0,5,.01)], pointsize=20)dazedANDconfusedMon, 29 Aug 2022 02:54:24 +0200https://ask.sagemath.org/question/63821/How to interpolate a curve from a set of pointshttps://ask.sagemath.org/question/63082/how-to-interpolate-a-curve-from-a-set-of-points/ I have a set of points on the plane, and I want to interpolate these points to make a smooth curve.
I tried with spline() or even creating the lagrange polynomial, but the problem is that with these options I can only interpolate functions (so for example, if I have a discrete set of points of a circle, I cannot get the circle with spline() since it will interpolate the points following te x-axis order).
Is there any option to interpolate a curve following the order of points given in the list?
JBFri, 01 Jul 2022 15:30:15 +0200https://ask.sagemath.org/question/63082/I 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/Evaluate variable in plot labelhttps://ask.sagemath.org/question/61903/evaluate-variable-in-plot-label/I have several plots with labels that I would like to evaluate. For instance
all=[plot(x^(1/(i+1)),(x,0,4), rgbcolor=hue(i/10),axes_labels=[r"$x$",r"$x^{1/(1+%d)}$"%i]) for i in range(4)]
leads to `all[2]` showing me (sorry for not being able to upload due to <60 points) the plot lablel $x^{1/(1+1)}$, which
I would like to display after evaluation ($x^{1/2}$)
By defining the function $f(i)=i+1$ in the preamble of the graph I still cannot evaluate $f$, for $i$ is not evaluated inside the list
Even supposing I would, suppose I want the exponent in digits form. I am unable to find the string splicing character which also evaluates and then displays 0.5 (instead of a single digit). Does anybody know about how to correct this syntax?
c.p.Sun, 10 Apr 2022 20:53:04 +0200https://ask.sagemath.org/question/61903/refresh with three.jshttps://ask.sagemath.org/question/61806/refresh-with-threejs/In some analysis/education projects I would like to compare different situations; like the Kerr GR diagrams which have lots of moving parts (sorry for the pun).
Which is to say: generate plot(s) ⇾ save as HTML (s)(or some such) ⇾ open the file(s) with a browser.
Then change plot parameters and resave and have the open pictures update automatically. Actually, I presume that the three.js would have them monitoring the HTML file as in:
[Stack overflow here:](https://stackoverflow.com/questions/5588658/auto-reload-browser-when-i-save-changes-to-html-file-in-chrome)
although a triggered update would be fine, but that answer seems simple enough to put in the three.js (template?) myself.
I realize that I could do the update manually in the browser toolbar; but being distractible and forgetful, it would be better to have it automatic. Although I am open to other suggestions.
I really enjoy moving around the parameter space as well as objects, visually oriented :); and I think sagemath does wonderful plots.rrogersSun, 03 Apr 2022 22:54:13 +0200https://ask.sagemath.org/question/61806/Plotting Zero-free regionshttps://ask.sagemath.org/question/61733/plotting-zero-free-regions/So I am working on a project for proving different types of zero-free regions, I needed to plot some zero free regions using sage and cannot think any obvious ways to do it. I am still pretty new to sage and computational math in general but I needed some guidance as to what I should do.
I am trying to plot the zero free region by de la Vall ́ee Poussin which is $1-\beta \leq \frac{c}{\log(t)}$prathamlalwaniTue, 29 Mar 2022 06:02:04 +0200https://ask.sagemath.org/question/61733/How to change the label text size of verticeshttps://ask.sagemath.org/question/61600/how-to-change-the-label-text-size-of-vertices/When I have a graph with over 1000 vertices, vertex label text is too small to read,
but it seems there is no method dealing with this issue?
I was only able to find the ticket #13827 from 6 years ago raising the same issue without a fix:
"fontsize affects to size of title font, not for vertex label or edge label font sizes."
Is there any way to change label text size?
DrewCThu, 24 Mar 2022 03:02:13 +0100https://ask.sagemath.org/question/61600/Contour Plot of 1/(2*pi*sqrt(x^2 + y^2)), why is it square? How to fix it?https://ask.sagemath.org/question/61288/contour-plot-of-12pisqrtx2-y2-why-is-it-square-how-to-fix-it/I plotted the contour plot of a function `1/(2*pi*sqrt(x^2 + y^2))`.
The code is below:
contour_plot(1/2/(pi*sqrt(x^2 + y^2)), (x, -0.1, 0.1), (y, -0.1, 0.1),
plot_points=20, colorbar=True)
**The output result is not round, but square! Why?**
**How to fix it?**Tube777tubeSat, 26 Feb 2022 15:44:14 +0100https://ask.sagemath.org/question/61288/TeX label and running list-variable simultaneously in a plot legend (or plot title)https://ask.sagemath.org/question/61112/tex-label-and-running-list-variable-simultaneously-in-a-plot-legend-or-plot-title/I want to use a `[... for n in ...]` to generate plots. How can I combine in a legend and/or title, TeX with the variable that runs (here $n$) to generate the list of plots? Minimal example:
some_plots=[plot(x^n,(x,0,1.1),title=r'$x^n$ where $n$ takes the value in the box
(format is not nice, though)',
legend_label=n, rgbcolor=hue(.1*n)) for n in range(0,10)]
sum(some_plots[s] for s in range(0,10))
which shows a box with colors, and, separately the title. How can I add $n$ to the box? If I combine TeX and the variable (like `$x^n$=n`) I get errors. (I cannot upload yet pictures, which would make the question very clear)c.p.Tue, 15 Feb 2022 16:15:27 +0100https://ask.sagemath.org/question/61112/Why specifying `stylesheet` parameter in plot function causes error?https://ask.sagemath.org/question/61081/why-specifying-stylesheet-parameter-in-plot-function-causes-error/I'm disappointed by how the default plot style looks, so I decided to find some fancier stylesheet.
The [official documentation](https://doc.sagemath.org/html/en/reference/plotting/sage/plot/plot.html) says:
> MATPLOTLIB STYLE SHEET OPTION:
>
> `stylesheet` - (Default: classic) Support for loading a full matplotlib style sheet.
> Any style sheet listed in matplotlib.pyplot.style.available is acceptable.
> If a non-existing style is provided the default classic is applied.
When I try it with a simple example, I get
plot(sin, stylesheet="ggplot")
...
RuntimeError: Error in line(): option 'stylesheet' not valid.
However I found that this alternative works:
plot(sin).show(stylesheet="ggplot")
This is ugly, because I use IPython CLI and want to be able to show the plot by this syntax
p = plot(sin)
p
without typing `.show()`.
Moreover, I'd like to configure my `.sage/init.sage` file so that the 'ggplot' stylesheet is used by default:
# .sage/init.sage
plot.options["stylesheet"] = "ggplot"
This doesn't work though, for sage substitutes this option into `line()` function which appears to have no such option.
**Questions:**
1. Is this a bug, or a mistake in (my understanding of) the documentation? Should it be reported and if yes, where is the best place to do it?
2. How do I achieve custom plotting style by default (perhaps by some setting in the `init.sage` file)?
I'm using SageMath version 9.5, Release Date: 2022-01-30 with Python 3.10.2, all downloaded from ArchLinux official repos.SageUserNickSun, 13 Feb 2022 12:44:24 +0100https://ask.sagemath.org/question/61081/max unevaled in plot??https://ask.sagemath.org/question/60976/max-unevaled-in-plot/Dear all,
Here is a puzzling code:
var('a')
show(plot(max([1-a, a]), (a,0,1)))
show(plot(max([a, 1-a]), (a,0,1)))
Only the first term of the list is used in this maximum!???
Any hint is welcome, I can sure plot a polygon made of sample points, this works, but I would rather understand why the above simple piece fails to behave as I would expect.
Many thanks in advance! OlivierOlivier R.Sun, 06 Feb 2022 23:57:58 +0100https://ask.sagemath.org/question/60976/Using Seaborn Graphing in Sagemathhttps://ask.sagemath.org/question/60594/using-seaborn-graphing-in-sagemath/ Seaborn is a matplotlib frontend that makes beautiful graphics by default, without a lot of fingerpainting like in straight matplotlib. I'm making some Sage graphs for publication and would like to format/display them with Seaborn. Is there a way to combine it with Sage's `plot` and `list_plot`, especially for axes labels?jaiaSun, 09 Jan 2022 08:05:32 +0100https://ask.sagemath.org/question/60594/LaTeX can't find file for text in plothttps://ask.sagemath.org/question/59948/latex-cant-find-file-for-text-in-plot/Apologies in advance if I've missed something obvious. I'm trying to add LaTeX text to a plot, e.g.
from matplotlib import rc
rc('text', usetex=True)
plot(x^2, legend_label=r'This is $x^2$')
and each time, I get an error message like this:
/opt/sagemath-9.3/local/lib/python3.7/site-packages/sage/repl/rich_output/display_manager.py:596: RichReprWarning: Exception in _rich_repr_ while displaying object: latex was not able to process the following string:
b'lp'
Here is the full report generated by latex:
This is pdfTeX, Version 3.141592653-2.6-1.40.23 (MiKTeX 21.10)
entering extended mode
! I can't find file `/home/sage/.sage/matplotlib-1.5.1/tex.cache/1acea6f6c115d0
ec7a634ed0529287b9.tex'.
<*> ....cache/1acea6f6c115d0ec7a634ed0529287b9.tex
Please type another input file name
! Emergency stop.
<*> ....cache/1acea6f6c115d0ec7a634ed0529287b9.tex
No pages of output.
Transcript written on texput.log.
RichReprWarning,
The file in question (1acea6f6c115d0ec7a634ed0529287b9.tex) does exist, but the path is
`/home/.sage/matplotlib-1.5.1/tex.cache/1acea6f6c115d0
ec7a634ed0529287b9.tex'
not
`/home/sage/.sage/matplotlib-1.5.1/tex.cache/1acea6f6c115d0
ec7a634ed0529287b9.tex'
For whatever it's worth, my home directory is `C:\Users\davis\` and if I copy the relevant file into the folder that LaTeX says it's looking for, and then run the same code, I get the same error message.
I'm on Windows 10 running Sage 9.3 (fresh installation this morning).xdavThu, 25 Nov 2021 10:38:33 +0100https://ask.sagemath.org/question/59948/ymin and ymax not workinghttps://ask.sagemath.org/question/59625/ymin-and-ymax-not-working/Running this code
f_x = (x**3 - x**2 + 3*x + 4) / (x**2 - 4*x + 3)
plot(f_x, (x, 0, 4), detect_poles=True, ymin=-100, ymax=100)
results in a graph with a max y of about 500000.
What am I doing wrong? The x-axis is limited, as I want, in the range 0 to 4.SageSun, 07 Nov 2021 14:26:58 +0100https://ask.sagemath.org/question/59625/ymin and ymax not workinghttps://ask.sagemath.org/question/59626/ymin-and-ymax-not-working/ When I run this code:
f_x = (x**3 - x**2 + 3*x + 4) / (x**2 - 4*x + 3)
plot(f_x, x+3, (x, 0, 4), detect_poles=True, ymin=-100, ymax=100)
the result is a graph with ymax ~ 500000 and ymin ~(- 1000). What am I doing wrong?SageSun, 07 Nov 2021 14:29:01 +0100https://ask.sagemath.org/question/59626/Why is Sage calling Wine to show 2D plots and how do I fix it?https://ask.sagemath.org/question/59536/why-is-sage-calling-wine-to-show-2d-plots-and-how-do-i-fix-it/This is a two-parter. Part the first is mainly out of curiosity. Part the second carries more weight.
I'm running an Arch (Manjaro) Linux machine. I have a fresh install of `sagemath` via `pacman`. My system is up to date, and I can open the `sage` console by calling it from the command line. I'd like to plot a 2D graph of a Brownian motion algorithm, but whenever I call it, Wine opens. The first time my graph was compiled, a dialog box opened and it said something along the lines of "Do you want to run this using Wine?". I clicked yes. It no longer shows up. I don't have the exact line. I uninstalled and reinstalled Sage and deleted the cache. I wasn't able to replicate the dialog box. Anyway.
Whenever I run `plot(<func>)`, the prompt reads back that it is launching a png viewer for a Graphics object, which I understand to be the correct output. But again, it opens in Wine via a Windows 95 looking Explorer window. Here's the path.
`file:Z:\home\def\.sage\temp\tower\17759\tmp_esqczsyp.png`
Why is Wine the default program to open a 2D plot? Curiously, I can show 3D plots just fine.dfarmi2Fri, 29 Oct 2021 19:37:09 +0200https://ask.sagemath.org/question/59536/Am I doing something wrong in plot or is this a bug?https://ask.sagemath.org/question/58967/am-i-doing-something-wrong-in-plot-or-is-this-a-bug/I put this into sagecell online and get a messed up plot. f(x) simplifies to 1.
f(x)=2/3*(cos(x)^2 + cos(x-(2/3)*pi)^2 + cos(x-(4/3)*pi)^2)
(plot( f , -4,4))
John Paul MorrisonSat, 11 Sep 2021 22:32:08 +0200https://ask.sagemath.org/question/58967/Plot with no scale on the y axishttps://ask.sagemath.org/question/57439/plot-with-no-scale-on-the-y-axis/ If I plot a function that generates huge numbers, then sage normalizes it between -1 and 1. I don't like this behaviour because it hides the real values on the y scale.
For example, if I do
plot(10^6 * x, -1, 1)
what I get is a plot between -1 and 1 on both the axis. Is there a way to have the values on the y axis with the right scale?stepFri, 04 Jun 2021 02:21:11 +0200https://ask.sagemath.org/question/57439/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/Adapt 2D-plot tick label attributes to dateshttps://ask.sagemath.org/question/51080/adapt-2d-plot-tick-label-attributes-to-dates/Is there a way to access ticks labels to rotate them? I've tried `Graphics.matplotlib()` and `set_rotation()`, but this doesn't seem to produce changes. Am I doing wrong things?
In the example below, the formatter and locator are working correctly, but the problem is all labels are oriented horizontally, messing all together since each tick label is a date and therefore quite long. Need to rotate them.
import csv
from datetime import datetime
from matplotlib import ticker
from matplotlib import dates
data = [('04/22/20', '04/23/20', '04/24/20','04/25/20','04/26/20', '04/27/20'),
(20, 40, 80, 160, 320, 640)]
labels = data[0]
labels = map(lambda x: dates.date2num(datetime.strptime(x, '%m/%d/%y')), labels)
labels = list(labels)
values = data[1]
values = map(lambda x: int(x), values)
# Z is a list of [(x1, y1), (x2, y2)...]
# x1, x2, ... are dates
# y1, y2, ... are values
Z = zip(labels, values)
Z = list(Z)
p = list_plot(Z, ticks=[1, None],
tick_formatter=[dates.DateFormatter('%d.%m.%Y'), None],
axes_labels=['Days', '$\\log \\;{N}$'], plotjoined=True,
thickness=2, figsize=4, scale='semilogy')
G = p.matplotlib()
labels = G.axes[0].xaxis.get_ticklabels()
labels = list(labels)
for label in labels:
label.set_rotation(45)
p
This outputs the plot with an ugly x-axis on which all the dates are messed up. How to fix that?
![Plot with dates as tick labels on the x-axis](https://i.imgur.com/14VIFv4.png)MrDvbnhbqMon, 27 Apr 2020 20:59:05 +0200https://ask.sagemath.org/question/51080/Background for plot should include axes and labelshttps://ask.sagemath.org/question/56826/background-for-plot-should-include-axes-and-labels/## Plots in Jupyter: Mathematica vs Sage
Below are four versions of a same plot in Jupyter notebooks in JupyterLab:
- light theme vs dark theme
- Mathematica vs Sage, using the Wolfram Language kernel
and the SageMath kernel
To reproduce, either use the notebooks: [mathematica](https://cdn.discordapp.com/attachments/531944364554059778/836651999353241610/jupiter-gravity-gradient-mathematica.ipynb) | [sage](https://cdn.discordapp.com/attachments/531944364554059778/836652569568739388/jupiter-gravity-gradient-sage.ipynb), or use the following code snippet:
f = 8.252e-5 - 0.035e-10*x
I = (0, 1e5)
labels = ["altitude in meters", "force difference in newtons"]
plot(f, I, axes_labels=labels)
and in JupyterLab, select light or dark via the "Settings > JupyterLab Theme" menu.
### Light theme
Left: Mathematica. Right: SageMath.
![](https://cdn.discordapp.com/attachments/531944364554059778/836205750984507402/sage-light.png)
### Dark theme
Left: Mathematica. Right: SageMath.
![](https://cdn.discordapp.com/attachments/531944364554059778/836205951635292190/sage-dark.png)
### Observation
In the SageMath plots,
- the font size is inconsistent between the axis labels and tick labels
- the white background does not include the axes or tick labels
if the plot does not extend to an area covering them;
as a consequence, in dark mode,
- the y-axis label and y-axis tick labels,
- the x-axis, x-axis label and x-axis tick labels,
are black on a black background, and cannot be seen.
### Question
Could i make the background permanently opaque,
and permanently change the font size to something
more reasonable like Mathematica has for reference?erentarTue, 27 Apr 2021 13:45:35 +0200https://ask.sagemath.org/question/56826/Formatting plot titlehttps://ask.sagemath.org/question/56685/formatting-plot-title/ I am not able to find formatting options for `title` for `plot`. Here's the code,
p1 = plot(fresnel_sin(t), (t, -pi, pi), ticks=[pi/4,0.1], tick_formatter=[pi,None], legend_label=r'$f(x) = \int_0^x \sin(\frac{\pi t^2}{2})dt$', axes_labels=[r'$x$', r'$f(x)$'], axes_labels_size=1.5, title='Fresnel\'s sin', title_pos=(0.5,1.1))
p1.set_legend_options(back_color=(0.9,0.9,0.9), shadow=False, font_size=14, loc=(0,0.7))
p1.show()
The `title` font is relatively small, I am not able to change it without making it look displeasing. I've tried the following modification,
p1 = plot(fresnel_sin(t), (t, -pi, pi), ticks=[pi/4,0.1], tick_formatter=[pi,None], legend_label=r'$f(x) = \int_0^x \sin(\frac{\pi t^2}{2})dt$', axes_labels=[r'$x$', r'$f(x)$'], axes_labels_size=1.5)
p1.set_legend_options(back_color=(0.9,0.9,0.9), shadow=False, font_size=14, loc=(0,0.7))
p2 = text('Fresnel\'s sin ', (1.5, 0.9), fontsize=14, color='black')
p1 + p2
But it's not what I want. Using `text` doesn't seem to do it(or so I think). Need some help here :).debojit2178Sat, 17 Apr 2021 12:59:34 +0200https://ask.sagemath.org/question/56685/Possible problem in bezier_path.pyhttps://ask.sagemath.org/question/56608/possible-problem-in-bezier_pathpy/ It seems that the path that is stored by BezierPath is not correct.
Let
p2d = [[(3.0,0.0),(3.0,0.13),(2.94,0.25),(2.8,0.35)],
[(2.7,0.44),(2.6,0.5),(2.5,0.5)],
[(2.36,0.5),(2.24,0.44),(2.14,0.35)],
[(2.05,0.25),(2.0,0.13),(2.0,6.1e-17)]]
then
bezier_path(p2d)[0].path
is different than the given path p2d. There are several consequences to this, for example, the stored path cannot be fed again to bezier_path, so this won't work (results in weird errors):
bezier_path(bezier_path(p2d)[0].path)
and also affects the plot3d method of the class.
The issue seems to stem from line 64 of bezier_path.py:
vertices = self.path[0]
Since the list of vertices changes size after the line so does self.path. I believe the line should be
vertices = deepcopy(self.path[0])RozaThSun, 11 Apr 2021 02:07:59 +0200https://ask.sagemath.org/question/56608/csc plotting helphttps://ask.sagemath.org/question/56334/csc-plotting-help/Hello,
I'm new to SAGE and am having trouble plotting a cosecant (csc) curve.
Here is my input:
plot(csc(x), (x,-3*pi, 3 * pi))
but the output doesn't show the curves approaching the asymptotes as I would expect.
What do folks think about this?
Thanks for the help!
-mattmzagrabeTue, 23 Mar 2021 17:17:18 +0100https://ask.sagemath.org/question/56334/