Open 38968367-17c9-42b1-b82d-c1adf20431c2 opened 14 years ago
Would this be like a density plot or contour plot? Even after consulting the internet I'm not quite sure what the difference would be, though perhaps a shortcut would be useful (?).
Attachment: two_positive_charges2d.png
Attachment: electric_dipole3d.png
I have just attatched two pictures of the intended results. Both are plots of electric potentials the first one comes with a plot_vector_field of the corresponding electric field.
I also attatched a picture of the 3d version, although I mean to make a new ticket for that once this one is finished.
It sounds like you are looking for a contour plot (?). Can you describe what command you used to create the first plot? Maybe we could make a shortcut to the specific type of contour plot you need, which would give the functionality you are looking for.
Yes! I had not seen that command. I used implicit_plot. Now that I've checked contour_plot it is exactly what I wanted.
The only thing I don't like is the automatic choosing of contour levels. They usually get too high values that concentrate around the poles of the function so that there are almost no curves in parts of the picture away from the poles. I'll make a patch to improve that.
Also, it seems like there's no contour_plot3d I'll also work on that.
Replying to @sagetrac-olazo:
Yes! I had not seen that command. I used implicit_plot. Now that I've checked contour_plot it is exactly what I wanted.
Great!
The only thing I don't like is the automatic choosing of contour levels. They usually get too high values that concentrate around the poles of the function so that there are almost no curves in parts of the picture away from the poles. I'll make a patch to improve that.
What I would do is leave the current functionality alone, but add an option for the sorts of situations you encounter - or something like that. You can also choose the contours you want - see
sage: contour_plot?
Also, it seems like there's no contour_plot3d I'll also work on that.
Have you tried implicit_plot3d
? Presumably one would use this to start.
Replying to @kcrisman:
What I would do is leave the current functionality alone, but add an option for the sorts of situations you encounter - or something like that. You can also choose the contours you want - see
Yes, that's what I was thinking of, add something like an ,avoid_poles=False
option. Yes, I have seen the option to choose the contours.
Have you tried
implicit_plot3d
? Presumably one would use this to start.
Yes, that is what I used to produce the 3d picture. I have just made #9669
Description changed:
---
+++
@@ -1,3 +1,10 @@
-This should be a function that plots a two variable funtion as a group of isolines along a given place of the xy plane.
+At this point contours of a function with poles get too concentrated near the poles. I'm adding a screenshot to exemplify the following code:
-
+```
+var('x y x0 y0 q')
+R=((x-x0)^2+(y-y0)^2)^(1/2)
+field=q/R
+q1=field(x0=1,y0=1,q=1)
+q2=field(x0=-1,y0=-1,q=-1)
+contour_plot(q1+q2,(x,-2,2),(y,-2,2),aspect_ratio=1,fill=False,labels=True,contours=20)
+```
Attachment: concentrated_contours.png
At this point contours of a function with poles get too concentrated near the poles. I'm adding a screenshot to exemplify the following code:
CC: @jasongrout
Component: graphics
Keywords: scalar, plot
Issue created by migration from https://trac.sagemath.org/ticket/8625