Ask Your Question

diana.davis's profile - activity

2023-08-20 12:47:50 +0200 received badge  Famous Question (source)
2022-09-19 12:45:58 +0200 received badge  Famous Question (source)
2022-09-19 12:45:58 +0200 received badge  Notable Question (source)
2022-09-19 01:25:37 +0200 commented answer Multiline string eats LaTeX tags due to backslash

Oh wow, I was just one keystroke from success. :) Thanks so much! It works perfectly now.

2022-09-19 01:24:01 +0200 marked best answer Multiline string eats LaTeX tags due to backslash

To create a multipage LaTeX document where each page is exactly the same except with a different name at the top, I want something like the following:

common_beginning = '{\bf To: '
list_of_names = ['Anna', 'Bev', 'Carlee']
common_end = """}

\footnotesize
This is small text.
\normalsize
Here is some more.
\newpage
"""

The issue is that when I compile the strings, I get:

common_beginning
'{\x08f To:'

common_end
'}\n\n\x0cootnotesize\nThis is small text.\n\normalsize\nHere is some more.\n\newpage\n'

In this example, it is eating the \b and the \f at the beginning of the LaTeX tags "\bf" and "\footnotesize". In my actual document, it eats the \n from "\newpage" and the \t from "\textwidth" as well. In any case, the backslashes really seem to mess things up. Is there a way around this?

2022-09-18 21:56:27 +0200 asked a question Multiline string eats LaTeX tags due to backslash

Multiline string eats LaTeX tags due to backslash To create a multipage LaTeX document where each page is exactly the sa

2022-06-18 11:20:13 +0200 received badge  Notable Question (source)
2022-06-18 11:20:13 +0200 received badge  Popular Question (source)
2020-01-10 00:02:16 +0200 received badge  Popular Question (source)
2019-02-18 02:17:50 +0200 received badge  Scholar (source)
2018-12-13 20:04:54 +0200 received badge  Supporter (source)
2018-12-13 16:44:56 +0200 received badge  Nice Question (source)
2018-12-13 16:28:27 +0200 received badge  Editor (source)
2018-12-12 01:01:11 +0200 received badge  Organizer (source)
2018-12-12 01:00:34 +0200 asked a question How to make points smaller than size 1 in point3d?

I am plotting a very large number of points in 3D, which I have in a list, using point3d. Below the same behavior is simulated for randomly generated points:

point_list = []

for n in range(10000):

....point_list.append((random(), random(), random()))

pic = point3d(point_list, color='red', size=1)

pic.save(figsize=20)

I would like the points to be very small, since there are so many of them. It seems that "size" can only take positive integer values. As a workaround in point2d, you can make "figsize" much bigger, and the points stay the same size in pixels, which has the effect of scaling the point size down. But in point3d, when you make "figsize" bigger, you get the same picture, bigger. Could anyone help me make the points smaller?

Additionally, the default is for each point to be displayed as a little sphere, but I want it to be just a point. Again, in point2d, the code

pic = point2d(point_list, color='black', size=1, marker='.' )

makes this happen, but when I do this in point3d they are still little spheres, and I cannot find any documentation about changing the marker for point3d.

2017-10-27 15:47:30 +0200 commented answer Can I import a graphic and add to it?

Thank you! This seems very promising. I used your code to try to add a red line on top of my image:

var('x')
p = plot(x,-2,2,color='red',aspect_ratio=1, figsize=12.3)
p.save('test.png')
import PIL
img = PIL.Image.open('pic.png')
img2 = PIL.Image.open('test.png')
img3 = PIL.Image.blend(img,img2,alpha=0.7)

I adjusted the figsize of the line image to be 12.3 so that it matches my "pic" image, and both images are 906 x 906. However, I still get the following error:

ValueError: images do not match

Do you have any suggestions? When I run just

img.show()

or

img2.show()

each associated image opens as a bmp in a separate window, so it seems that the files are treated equally.

2017-10-27 02:02:21 +0200 received badge  Student (source)
2017-10-27 02:01:07 +0200 asked a question 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.)