I have a few graphs which took quite some time for calculations. I would like to extract the data of those plots instead of recalculing a list. I found the command pts=Cases[(*I paste graph here*),x_Line:>First#x,Infinity];, which works fine for my line plots but not for listplots. How can I do the same for listplots?
It is essentially the same except for a scatter plot you use point:
Cases[(*pasted graphic*), x_Point :> First#x, Infinity]
It may be instructive to do
(*paste*)//FullForm
Of course you really ought to just save the data before generating the plot..
Related
my brain is pickled with this one. Below are the two graphs I have plotted with exp2 function. The points do not match the curve, and this is ultimately changing my entire answer, as it is giving the wrong values out, and I cannot understand why?
enter image description here
enter image description here
Here is the code I am using, both graphs plot a concentration against time, but yet give different results:
CH4_fit = fit(Res_time, CH4_exp, 'exp2'); CH4_coeff =
coeffvalues(CH4_fit);
%Co-efficient values for exponential fitting CH4_pred
=(CH4_coeff(1)*exp(CH4_coeff(2)*Res_time)) + ...
(CH4_coeff(3)*exp(CH4_coeff(4)*Res_time)); plot(Res_time,CH4_exp, Res_time, CH4_pred);
Can I just added that the exact same data was run on different computers, and it gave the same equation co-efficients exactly (to 4.dp) and the same times, but yet still outputs different concentrations on my version? I have the R2018b, and I have just used default settings (don't know how to change anything, so I definitely haven't).
I try to write an export of an 3-d plant modelling software to Three.js but got stuck with the rotations and translations of the objects.
So far I tried to use quaternions and transformation matrices but both results are not satisfying. For my tests I use a simple binary tree that originally looks like this:
the results of my export are this:
You can find the code of both export under
http://ufgb966.forst.uni-goettingen.de/three/test2Quaternion.html
http://ufgb966.forst.uni-goettingen.de/three/test2Matrix.html
It seams that my rotations are made around the wrong point. Each rotation should be done around the origin of each geometry. What would be a method to achieve the result I'm looking for?
Just in case you haven't already, you might want to take a look at this: Using Matrices & Object3Ds in THREE and this How to use matrix for transformation, it helped me out. Also note that three.js uses a right handed coordinate system which you probably know.
If you export from blender, try -Z Forward, Y up.
In my opinion you must change sequence of translation and rotation transformations - the problem is in transformations sequence.
I’m learning how to use SphericalPlot3D. I’m using the following statement:
SphericalPlot3D[Cos[θ],{θ,0,π},{ɸ,0,2 π}]
I was expecting to get a cosine curve along y-axis rotated around the same axis. More or less like an hourglass. What I get is a sphere. What do I have to specify in SphericalPlot3D in order to get rotated vertical cosine?
When I use the following statement:
SphericalPlot3D[Cos[2 θ],{θ,0,π},{ɸ,0,2 π}]
I would expect to get 2 hourglasses, one standing on the other along y-axis. I get something different. Where do I go wrong?
Thanks/Mikael
I guess, what you wanted is a surface or revolution with a cosine shape rotated about one axis to get a Hourglass. It is more a Cylindrical plot. The Spherical Plot more or less bends the top and bottom together to form a kind of sphere.
My solution for your problem would be:
RevolutionPlot3D[{Cos[t], t}, {t, 0, π}, {ɸ, 0, 2 π}]
which gives the following plot:
This may be a bit late, but a friend of mine just had the same problem so I thought I'd document the solution somewhere.
The confusion comes from the way in which Mathematica defines θ and φ. In most cases they're defined as follows:
However, Mathematica actually defines θ as what you think should be φ and φ as what you think should be θ for some reason. The following screenshot is taken from the documentation page for SphericalPlot3D explaining these definitions.
A simple fix to this is to swap the way you define the variables when calling SphericalPlot3D. So instead of writing
SphericalPlot3D[Cos[2 θ],{θ,0,π},{ɸ,0,2 π}]
You would want to write:
SphericalPlot3D[Cos[2 θ],{ɸ,0,2 π},{θ,0,π}]
I have some data from model in Femlab. Because I would like to work on the results more, I would like to use Octave / Gnuplot as well to visualize the computed data. I have exported the data from Femlab into a txt file in form "x y z value" (4 columns). Everything unsorted - than can I do. But how to get this into gnuplot? I can choose one of the variables to fix it(let's be it x) and plot the rest y,z and value by splot. But, I have thousand and thousand of numbers and this is not possible, than Femlab doesn't keep the variables fixed (so you sort it along x and find out that there are no two x values the same).
I know about Femlab / Matlab interface, but unfortunately I havent Matlab.
Thank you in advance!
Have you tried scilab? It is a matlab clone like octave and seems to support some FEM stuff: http://wiki.scilab.org/Finite%20Elements%20in%20Scilab.
See also http://www.utc.fr/lrm/giens05/CDROM/CDROM/lo01.pdf a paper where they interface Scilab and OpenFEM.
Is it possible that when I Plot a function in Mathematica, it will automatically put near it it's equation(i.e. y = 2x) or even some other text?
At first glance I don't find any option for it, but if there is one I'd like to know.
Thanks
Using Mathematica 6 or higher, I often use Tooltip to help me identify plot curves:
Plot[Tooltip[Sin[x]], {x, 0, 8 Pi}]
Alas, this is only useful when using the graph interactively since you must hover the mouse cursor over the curve. It doesn't work so well on paper or on a static image.
You can use the Epilog option to manually place some text on the plot, as in this example:
Plot[
Sin[x], {x, 0, 8 Pi},
Epilog -> Text["My Text", Offset[{32, 0}, {14, Sin[14]}]]
]
Tweak the arguments of Offset to taste.
This works if you do not mind manual placement. Automatic placement poses some challenges, depending upon the kinds of functions that you wish to plot. But if you know something of the general characteristics of the functions of interest, you could write a function that calculates nice looking values for the Offset arguments. For example, if I knew I was going to plot lots of exponential decline functions, I might define something like the function myPlot in this example:
SetAttributes[myPlot, HoldAll]
myPlot[function_, {var_, min_, max_}] :=
Plot[
function, {var, min, max},
Epilog -> Text[function, Offset[{40, 0}, {var, function} /. var -> min + (max - min)/20]],
PlotRange -> All, AxesOrigin -> {0, 0}
]
... where the arguments to Offset are computed automatically using some arbitrary constants that work reasonably well for these kinds of plots:
Manipulate[
myPlot[1000 E^(-d t), {t, 0, 100}, "My Label"],
{d, 0.01, .2}
]
Since all of these options are programmable, the sky's limit as to how much sophistication you could code up for the label placement. Of course, such programming drifts farther and farther away from the ideal of a built-in option to Plot that just magically drops on some text next to the function. Mathematica 8 or 9 maybe :)
One way to do this, which automatically associates the expression with the style used to plot it, is to use the PlotLegends standard add-on package. The output doesn't look very good by default; I recommend setting the LegendShadow -> None option and using Style on the expressions you stick in the legend to make them look better. Also, loading the package inflicts some funny redefinitions on Plot and related functions which can break some other things if you're not careful.
"Near its equation" is the problem. This isn't an easy problem to solve, and it becomes somewhat impossible when you start getting "busy" graphs with overlapping plots and so on.
I don't have a good example to show, but usually I'll define a "labelling function" that takes the same input as the function being plotted, which places a dot on the graph and writes some text nearby. This has the advantage of being able to easily vary the location of the text but still have it tied to the function.