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.Sun, 23 Feb 2020 20:14:11 -0600- Gridlines, ticks and the like in polar coordinateshttp://ask.sagemath.org/question/50045/gridlines-ticks-and-the-like-in-polar-coordinates/Hello to everyone,
I'd like to produce a polar plot with thecorresponding "polar grid" in it (i.e. the lines corresponding to $\theta = $ constant, and the circles $r = $ constant appearing. Also, I would like to have something like the tick markers. I guess I could do something like this manually, but seems very unelegant... An idea?
JCJCSun, 23 Feb 2020 20:14:11 -0600http://ask.sagemath.org/question/50045/
- 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/
- How to show on a plot minor gridlines with a different thickness?http://ask.sagemath.org/question/26244/how-to-show-on-a-plot-minor-gridlines-with-a-different-thickness/ Assuming I have some data points to plot, say x and y:
import numpy as np
x = np.linspace(0, 1)
y = np.sin(4 * np.pi * x) * np.exp(-5 * x)
I tried plotting them like this:
line(zip(x, y)).show(frame=True, gridlines='minor', axes=False)
In the documentation I read about options for gridlines, including style for vertical and horizontal ones separately, but what about minor and major separation?
What I want is something like this with major lines thicker than minor:
import matplotlib
from matplotlib.pyplot import figure
f = figure(figsize=(8,8))
axes = f.add_axes([.1, .1, .8, .8])
axes.plot(x, y)
axes.grid(True)
axes.get_xaxis().set_minor_locator(matplotlib.ticker.AutoMinorLocator())
axes.get_yaxis().set_minor_locator(matplotlib.ticker.AutoMinorLocator())
axes.grid(b=True, which='minor', linewidth=.2)
axes.grid(b=True, which='major', linewidth=1)
f.savefig('plog.png')
Image: http://postimg.org/image/tgwb8qjsh/
![plot](http://postimg.org/image/tgwb8qjsh/)
EugeneWed, 18 Mar 2015 13:42:43 -0500http://ask.sagemath.org/question/26244/
- can gridlines be painted at sqrt(2) ?http://ask.sagemath.org/question/8018/can-gridlines-be-painted-at-sqrt2/In this simple plot
plot(x,0,2,gridlines=([1],[]))
the gridline is plotted alright. However, if I put sqrt(2) instead of 1
plot(x,0,2,gridlines=([sqrt(2)],[]))
does not work. It is strange, because I think that gridlines should behave similar as ticks. For instance, the following both two expressions work
plot(x,0,2,ticks=([sqrt(2)],[]))
plot(x,0,2,ticks=([sqrt(2)],[]),gridlines=true)
Does anybody know what is the reason or how to fix it?
Thanks.
Javier PĂ©rez.mathematicboyTue, 22 Mar 2011 03:28:58 -0500http://ask.sagemath.org/question/8018/