remove inner grid when placing frame around plot - wolfram-mathematica

Please see this MWE:
Plot[x, {x, -1, 1}, Frame -> True]
There is one horizontal and one vertical line drawn that crosses zero - how do I remove these lines? I tried GridLines->None, but that did not work.

Ever the rep-whore, here's my original comment made into an answer:
try adding Axes->False to the options in your Plot command.

Related

plot piecewise function in matlab

This is my code:
p=.2;
x=-1:20;
px=p*(1-p).^(x-1).*(x>=1);
Fx=cumsum(px);
figure;
subplot(2,1,1);
stem(x,px);
subplot(2,1,2);
stairs(x,Fx);
hold on;
stem(x,Fx,'w.')
I want to draw a circle mark at the right end of each horizontal line on the second subplot. Could someone show me how to do? Thanks in advance~
Things like following figure, but move the circle to the right end of each line.
You can use plot or scatter to draw the red circles.
Add one of the following instructions at the end of your script, they give the same output.
% Option 1: using plot
plot(x+1,Fx,'or');
% Option 2: using scatter
scatter(x+1,Fx,'r');
As you can see, my approach was to simply add 1 to every element of x. This is essentially shifting your data 1 unit in the x direction.
This is what you get:

Display image at desired scale across subplot axes

Is it possible to display an image in multiple subplot axes, such that the image appears at the desired scale?
subplot(3,3,[1 4 7]);
%# image scaled down to fit 1 set of axes
imshow(img);
subplot(3,3,2);
plot(relevantData);
%# And so on with 5 other plots
I want to have the image scaled to either a fixed size or to fit the axes available to it, rather than to the size of a single axes.
My use case is to show a video alongside plots derived from the video, such that the plots are progressively drawn in step with the video. Once the display is correct I can save each image and combine them into a video.
Clarification
I am asking if it is possible to produce a figure as described without specifying the position of every element in absolute terms. Though one can make arbitrary figures that way (and in fact I have done so for this project), it is very tedious.
Edit:
For changing the size of the subplot:
In help subplot they mention that you can set parameters on the selected "axes" (that's what they call a plotting area in Matlab).
Using that, you can set the 'position', as seen in help axes. This property takes takes as argument:
[left, bottom, width, height]
As pointed out by #reve_etrange, one should use absolute positioning for axes 'Position'and 'OuterPosition' parameters. they can be in normalized coordinates, though.
For changing the size of the image in the subplot:
I think there are 2 useful things for you in the help imshow output:
'InitialMagnification': setting the magnification of the image.
'Parent': determines which parent imshow will use to put the image in (never tried using imshow with subplots).

Placing Several 3D Objects in Mathematica Together in the Same 3D Box

I have a 3D surface created by the ListPlot3D in mathematica. The surface itself is relatively planar and in the arbitrary plane xy. I would like to place this surface on top of a molecule either generated from the ChemicalData function or inputted from a .pdb or other molecule input. This molecule is also planar and placed again the in the xy plane. I would like these two 3D objects to be separated by some z distance.
The end hope is that I will have a potential energy surface placed above this planar molecule that will still be rotatable in 3D. I have been using the Show and Graphics 3D options to no success. The x,y points on the surface correspond to x,y points on the 3D molecule, however they can easily be scaled and shifted as needed. As an option of last resort I suppose I could input the x,y,z coordinates of the atoms and use the PointListPlot3D command with various options to mimic the look of the molecule but this seems to be much more complicated then it needs to be.
Another approach that could be possible is if both of the 3D objects are converted to 3D boxes and simply stacked on top of each other. However I have not found this functionality as of yet in mathematica. Does anyone have any ideas on how to do this?
PES = ListPlot3D[{{0., 0., -2.04900365`},..., {0., 0.3, -2.05743098`}}]
Show[Graphics3D[ChemicalData["Benzene","MoleculePlot"]],PES]
The issue was the scale of the molecule versus the scale of the energy surface.
The units, as best I can tell, are in picometers. However their atomic distance seem to be off by 3%.
As an update to this it became much simpler to take the xyz coordinate of the molecule and hand generate the objects. It has been some time but I believe if you only state:
ChemicalData["Benzene","MoleculePlot"]
Mathematica will show you the format. If you do many of these a fairly simple python script can be made.
What Szabolcs said and I also did not get from your question why wouldn't something like this work?
Show[Graphics3D[
Rotate[ChemicalData["Caffeine", "MoleculePlot"][[1]],
45 Degree, {1, .5, 0}]],
Plot3D[-200 + 50 Sin[x*y/10000], {x, -100 Sqrt[3*Pi],
100 Sqrt[3*Pi]}, {y, -100 Sqrt[3*Pi], 100 Sqrt[3*Pi]},
ColorFunction -> "TemperatureMap"], Axes -> True]
ListPlot3D returns a Graphics3D object, so you should be able to combine it with other Graphics3D objects...
lp = ListPlot3D[ RandomReal[{}, {50, 3}], Mesh -> None];
sp = Graphics3D[Sphere[]];
Show[sp, lp, Boxed -> False]
although getting everything the same size will be the challenge...

OpenGL ES - Draw Triangle with line only?

Is there a way to draw a triangle with line only ?
I think GL_TRIANGLES option make triangle filled with color.
Set the fill mode with glPolygonMode(face, model):
glPolygonMode(GL_FRONT_AND_BACK,GL_LINE);
You have to set this every frame
Is there a way to draw a triangle with line only?
Use GL_LINES, GL_LINE_STRIP , or GL_LINE_LOOP (difference see here) with the same vertices that you use for GL_TRIANGLES.
if you are only rendering a single triangle at a time you can use GL_LINE_LOOP. it will connect the first and last, so if you have more than one triangle, it won't work.

mesh in mathematica

How can you plot a finer mesh like at noninteger values or something? My function is defined for only a very narrow range and Id like to visualize it better with the mesh. Also how do you make the function white? There is no "White" ColorData.
Your color question:
The default color is white for plots, with different colored lighting being used by default to make the plot appear non-white.
You can use the Lighting option (Lighting -> "Neutral") to get non-colored lighting in 3D plots. Then the result is white/grayscale:
Plot3D[Sin[x y], {x, 0, 3}, {y, 0, 3}, Lighting -> "Neutral"]
Your mesh question:
More information or an example is needed to answer this question. But try examining the PlotPoints option in the documentation to start.

Resources