Tag Info

New answers tagged

2

This method is based on Mr. Wizard's answer (updated for V10) to About the number format in ticks, which I discovered investigating another question, Change only tick labels while keeping default ticks, that in meantime was marked as a duplicate of this one. Since the method presented in the accepted answer by FDSg no longer works (currently the only other ...


1

Possibly what you want: listb = {{{0, 0}, {0, -0.1}}, {{1, 0}, {0, 0.1}}}; gr = Graphics[{Arrowheads[Norm@#2/5], Arrow[{#1, #1 + #2}]} & @@@ listb]; Rasterize[Framed[gr, FrameMargins -> 0], ImageSize -> 1000] See all the options of Framed for customization.


3

See this question and answer, since this is a duplicate, I think. Part of the problem has to do with code formatting, so I've answered anyway. Here is a simple example of what you might want. For the purposes of illustration, I have defined p1 = Plot[x^2, {x, 0, 1}]; p2 = Plot[x, {x, 0, 1}]; Then: Labeled[ Show[p1, p2 , ImageSize -> Large , ...


5

I don't know a way to export a figure with different resolutions for different elements, the term "resolution" normally applies to the whole figure. You have a 350 printer's points wide figure which you seemingly wish to export with resolution 1200 dpi. This means that you wish to export a figure with width Round[1200*(350/72)] 5833 pixels. Not every ...


4

Will this work for you? fticks[min_, max_] := Table[If[FractionalPart[i] == 0., {i, Round@i, 0.02}, {i, ""}], {i, Floor[min], Ceiling[max], 0.1}] Graphics[{EdgeForm[Opacity[0.5]], Opacity[0.75], ColorData[24, 6], Disk[{1, 0.5}, {1, 0.5}]}, Frame -> True, PlotRangePadding -> 0.5, ImagePadding -> 30, FrameTicks -> {{Automatic, ...


3

CorelDRAW is not a PostScript viewer. Its ability to import EPS files has serious limitations and is not guaranteed to preserve the original appearance of the figure. One workaround is to place the EPS file inside of the CorelDRAW document instead of importing it but it has a drawback: you will see only EPS preview, not the actual content of the EPS file. ...


2

I think your syntax is wrong. Try the following Export[pathWithFileName, mmaImageName, "EPS"], where pathWithFileName contains the path and the name of the exported file i.e. "path/filename.eps". In my answer the option "EPS" is not necessarily needed.


1

The issue, as I understand it, is to display a graphic with its ImageSize proportional to its "real" size. So, in an ideal world one would use something like plt=Graphics[ ... ]; plt=Show[plt, ImageSize -> AbsoluteOptions[plt, RealSize][[1,2]]/scalefactor] The problems are, there may be no Option equivalent to RealSize and, if there is, ...


2

pts = {{{1, 0}, {0, 1}}, {{3, 2}, {1, 0}}, {{0, 5}, {3, 2}}, {{-5, 0}, {0, 5}}, {{3, -8}, {-5, 0}}, {{16, 5}, {3, -8}}, {{-5, 26}, {16, 5}}, {{-39, -8}, {-5, 26}}}; aF = With[{scale = #}, Graphics[{Arrowheads[scale Norm[Subtract @@ ##]], Arrow@#} & /@ #2]] &; aF[1/300, pts]


8

kglr's very useful trophy from the land of undocumented functions needs to be recorded. Suppose you have the following plot: Plot[Sin[2 Pi t], {t, 0, 1}, ImageSize -> Tiny] Then you can just cut and paste {100, 54} Note, however, that Predictions`getImageSize actually reports ImageSize plus ImageMargins, as shown in the listing below. ...


1

Your problem arises from another Graphics option,PlotRange, having the default value Automatic, which gives each Graphics object its own plot range. To get what you want you will need to force each Graphics object to have the same plot range. Here is something that works for your example. I have made it a little more general than needed because I think you ...


10

ladderF = SetProperty[EdgeDelete[GraphData[{"Ladder", #}], {1 <-> 2, (2 # - 1) <-> (2 #)}], {EdgeStyle -> Black, VertexStyle -> Black, VertexSize -> Thread[{1, 2, 2 # - 1, 2 #} -> 0]}] &; ladderF@8


8

n = 10; GridGraph[{n + 2, 2}, EdgeStyle -> {1 <-> n + 3 -> Opacity[0], n + 2 <-> 2 n + 4 -> Opacity[0]}, BaseStyle -> Black, VertexShape -> {1 -> Null, n + 2 -> Null, n + 3 -> Null, 2 n + 4 -> Null}]


6

n = 9; Graphics[ {Line[{{{1, 0}, {1, n}}, {{2, 0}, {2, n}}}], Line@#, PointSize[0.2], Point /@ #} & @ Table[{x, y}, {y, n - 1}, {x, 2}] ]


11

I believe you want "FrontFaceColor" which can be found as a specification in this list: Graphics[{FaceForm[RGBColor[2/3, 1/3, 2/3]], EdgeForm[Black], Dynamic[{If[CurrentValue["MouseOver"], Darker @ CurrentValue["FrontFaceColor"]], Disk[]}]}] You may also find "FrontFaceOpacity" of use. Simply guessing I found that "BackFaceColor" is also ...


2

Here's my take. You can use either newVisibleSpectrum[] or myVisibleSpectrum[] as the underlying ColorFunction; I'll use the latter. (* smooth step function *) smoothStep3 = Compile[{{a, _Real}, {b, _Real}, {x, _Real}}, With[{t = Min[Max[0, (x - a)/(b - a)], 1]}, t*t*(3 - 2 t)], ...


1

ListPlot[Table[RandomReal[], {20}, {2}], AxesLabel -> {"x", "y"}] ListPlot[ReIm /@ Table[RandomReal[] + I RandomReal[], {20}], AxesLabel -> {"Re", "Im"}] If you want arrows: Graphics[Arrow /@ ({{0, 0}, #} & /@ ReIm /@ Table[ RandomReal[{-1, 1}] + I RandomReal[{-1, 1}], {20}]), Axes -> True]


2

Use Export gg = GraphicsGrid[Table[Plot[a*x^n, {x, 0, 1}], {n, 2}, {a, 2}]]; Export["test.jpg", gg]; Import["test.jpg"] You can use other formats such as "test.gif" or "test.png"


7

Alright, I managed to borrow a computer. Here's an implementation of my suggestion: ellipseIntersections[mat1_?MatrixQ, mat2_?MatrixQ] /; Dimensions[mat1] == Dimensions[mat2] == {2, 3} := {\[FormalX], \[FormalY]} /. RootReduce[Solve[Flatten[Map[ GroebnerBasis[Append[Thread[{\[FormalX], \[FormalY]} == #], ...


3

Another Method with the hep of J.M.'s suggestion use GroebnerBasis[] to produce the implicit Cartesian equations of the two ellipses, and feed those equations to Solve[]. $$\begin{cases} x=a_1 \text{sin$\theta $}+b_1 \text{cos$\theta $}+c_1 \\ y=d_1 \text{sin$\theta $}+e_1 \text{cos$\theta $}+f_1 \\ \end{cases}$$ $\Rightarrow$ $$ ...


4

As said in the comment by J.M, with the help of Graphics`Mesh`FindIntersections However, this method with lose the tangent points newSolution[mat1_, mat2_] := Module[{graph, pts, start1, start2}, graph = ParametricPlot[ {mat1.{Sin[θ], Cos[θ], 1}, mat2.{Sin[θ], Cos[θ], 1}}, {θ, 0, 2 Pi},Epilog -> {Point[{.1, .2}]}]; start1 = ...


4

You can also approach this using images (rather than graphics). The command ColorCombine places image a in the red channel, b in the green channel, and c in the blue channel: Nx = 10; Ny = 10; a = Table[RandomReal[], {i, 1, Nx}, {j, 1, Ny}]; b = Table[RandomReal[], {i, 1, Nx}, {j, 1, Ny}]; c = Table[RandomReal[], {i, 1, Nx}, {j, 1, Ny}]; ...


4

Or, if you want to produce a Graphics directly, these produce identical results: Graphics@Raster@Transpose[{a, b, c}, {3, 1, 2}] Graphics@Raster[MapThread[List, {a, b, c}, 2]]


3

It is as simple as Nx = 10; Ny = 10; a = Table[RandomReal[], {i, 1, Nx}, {j, 1, Ny}]; b = Table[RandomReal[], {i, 1, Nx}, {j, 1, Ny}]; c = Table[RandomReal[], {i, 1, Nx}, {j, 1, Ny}]; ArrayPlot[Transpose[{a, b, c}, {3, 1, 2}], ColorFunction -> RGBColor] Now you can set ColorFunction -> RGBColor and you probably want to look into ...


3

g = Graphics[{PointSize[.02], Point[{9, 5}], Point[{2, -5}], Point[{5, 5}], Point[{3, 6}], Point[{1, 1}], Point[{5, -7}], Point[{-7, 4}], Point[{6, -10}], Point[{-6, -2}], Point[{0, 8}], Point[{1, 4}], Line[{{1, 4}, {2, 5}}], Point[{2, 5}]}, AspectRatio -> Automatic]; g /. Point -> (Circle[#, .5] &)


1

You may do as follows. The function below shows a single trajectory: traj1[eq1_, eq2_, point_, col_, tmax_, n_] := Module[{p0, p1, p2, p3, tau, s}, eq3 = x[0] == point[[1]]; eq4 = y[0] == point[[2]]; s = NDSolve[{eq1, eq2, eq3, eq4}, {x, y}, {t, tmax}, Method -> "StiffnessSwitching"]; tau = ...


3

Just add a replacement at the end: Graphics[{Arrowheads[Norm@#2/0.0001], Arrow[{#1, #1 + #2}]} & @@@ listb] /. {_Arrowheads, Arrow[{a_, b_}] /; Norm[a - b] <= 10^-7} -> {} Update The problem seems to be a dot at the end of the arrow under certain conditions. a = 10^-8; listb = {{{0, 0}, {2.1*a, -2.1*a}}, {{1, 0}, {2.1*a, 2.1*a}}}; ...


2

How about Chop-ing the Arrowheads size to zero below a certain threshold? {Arrowheads[Chop[Norm@#2/0.0001, 1/100]], Arrow[{#1, #1 + #2}]} & @@@ listb


5

Just to illustrate the point I made in the comment, let's take a data set where the points stack up vertically, and verify what it looks like if we visualize their density by means of a color gradient as in the question One-dimensional heatmap. You first have to copy the definition of heatMap from the second code block in my answer, and then execute this: ...


5

Here is a possible implementation of rug representation using ListPlot. Maybe implementation from @MarcoB is more efficient. jitter function Here is a implementation of jitter function: jitter[x_] := Module[{r, z, xx, d}, r = {Min[x], Max[x]}; z = First@Differences[r]; z = If[z == 0, Abs[r], z]; z = If[z == 0, 1, z]; xx = ...


7

Let's generate some data to play with: SeedRandom[5] Round@RandomVariate[UniformDistribution[{0, 20}], 35]; data = {#, 50 - 3 # + RandomReal[{-10, 10}]} & /@ %; ListPlot[data, PlotRange -> All] Here is a function that calculates the size and position of the plot "piles" and constructs the plot explicitly from graphics primitives: Clear[rugplot] ...


8

[Edit notice: Updated to allow the setting of the vertical direction of the plot and to fix an error.] Here is a slight generalization of my answer to Isometric 3d Plot. To get an isometric view, we need to construct a ViewMatrix that will rotate a vector of the form {±1, ±1, ±1} to {0, 0, 1} and project orthogonally onto the first two coordinates. ...


9

I've written a package that allows you to easily generate images of self-similar sets in the plane. Here is a zip file containing that package, as well as a related package for digraph self-similar sets. Here's an example of its use that seems related to your needs. We first load the package, after placing it in our $Path, as described in the installation ...


4

Let's give you some freedom of choice here and since you explicitly avoided Manipulate, let's start with this. The piece that creates the plot, the rectangle and the triangles will almost be the same in all three examples. In all three examples, I will use locators, that have no appearance but will be forced to stay on the y=0 line, so that they are always ...


2

This should do it. leftTriangle = Magnify[Graphics[{Directive[ColorData[1][1], Opacity[0.5]], Triangle[{{-1, 1}, {0, 0}, {-1, -1}}]}, AlignmentPoint -> Left], 0.1]; rightTriangle = Magnify[Graphics[{Directive[ColorData[1][1], Opacity[0.5]], Triangle[{{1, 1}, {0, 0}, {1, -1}}]}, AlignmentPoint -> Right], 0.1]; plot = Plot[Sin[x], {x, -Pi, ...


3

Not sure if this will help in other examples but you can do it like this: sol = (y /. Solve[Sin[x^2 - y] == 0, GeneratedParameters -> a] // Normal) /. a -> (a &); fun = Flatten@Table[sol, {a, -2, 1}]; p1 = Plot[fun, {x, -1, 0}, Axes -> False, Frame -> True, PlotStyle -> Directive[Dashed, Thick]]; p2 = ContourPlot[Sin[y - x^2] == ...


4

func[cplot_, cf_, s_] := With[{cp = cplot}, pt = cp[[1, 1]]; lines = Cases[cp, Line[x__] :> x, -1]; max = Max[#[[All, 2]]] & /@ (Part[pt, #] & /@ lines); Show[Graphics[ GraphicsComplex[pt, MapThread[{cf[Abs[Rescale[#1, {Min[max], Max[max]}] - s]], Thick, Line[#2]} &, {max, lines}]], Frame -> True, AspectRatio ...


9

If it is acceptable to order the lines by the y value of the first point in each contour we can use a modification of Pickett's method: plot = Show[{ContourPlot[Sin[y - x^2] == 0, {x, -1, 0}, {y, -10, 10}], ContourPlot[Sin[-y - x^2] == 0, {x, 0, 1}, {y, -10, 10}]}, PlotRange -> All]; cols = {Red, Black, Blue, Orange, Green, Pink, Brown}; ...


6

You can manipulate the expression manually: plot = ContourPlot[ Sin[y - x^2] == 0, {x, -1, 1}, {y, -10, 10} ]; plot /. {a___, l : Longest[Line[_] ..], b___} :> {a, Riffle[Array[ColorData[97], Length@{l}], {l}], b} In order to find the pattern it helps to look at plot // FullForm. ColorData[97] is the list of default colors for Mathematica ...


2

Another way using Graphics primitives Raster and Text: dimdata = Reverse@Dimensions@data; map = data[[All, ;; -2]] // Raster[#, {{0, 0}, Reverse@Dimensions@#}, MinMax@#, ColorFunction -> "Rainbow"] &; text = Text @@@ Thread[{data[[All, -1]], Thread@{First@dimdata, Range[Last@dimdata]} - 0.5}]; then Graphics[{map, text}, AspectRatio -> ...


2

I copied the example curve from @Rahul's answer, but I think it's a lot faster to just use two Line primatives if you'd like a 2D look for the curves. The trick is to place a thicker line with the background color very slightly behind the curve you are rendering, I did this by subtracting off a small fraction of the ViewPoint vector. The disadvantage this ...


6

Updated code Based on some wonderful comments below, here is some simplified, more robust code. MatrixPlot[ PadRight[Drop[data, None, -1], Dimensions[data]] , ColorRules -> {0 -> White} , Epilog -> MapIndexed[ Text[#1, Flatten[{Last[Dimensions[data]] - 0.5, #2 - 0.5}]] & , Reverse@data[[All, -1]] ] ] Original code Does this ...


1

To use the JavaGraphics package, run the following text in the kernel: <<JavaGraphics`


4

I will expand on Szabolcs's answer. Starting with the same triangulation, we can see that the problematic cells consist of "triangle" whose vertices are collinear. These have areas that are either negative (wrong orientation), zero, or nearly zero (below 2.*^-15). They arise no doubt from round-off error. I could not find any means of improving the ...


24

You can also construct the image from Graphics primitive, which ultimately may give you more control: spectrum[list_List] := Graphics[ {Thickness[0.005], ColorData["VisibleSpectrum"][#], Line[{{#, 0}, {#, 1}}]} & /@ list, PlotRange -> {{380, 750}, {0, 1}}, PlotRangePadding -> None, ImagePadding -> All, AspectRatio -> 1/5, ImageSize ...


12

I prefer ListDensityPlot here as it gives flexibility to plot a range of data points. First of all, I define a function which generates a narrow spectrum around our desired wavelength: spec[wavelength_, width_] := Flatten[Table[{{x, 0, x}, {x, 1, x}}, {x, wavelength - width, wavelength + width, 0.1}], 1]; where we can specify wavelength and width of ...


2

Very simple error. You must give a second argument to Table which gives the interation specifications. min = {{1, 1}, {2, 2}, {2, 3}}; Graphics[{EdgeForm[{Thin, Blue}], White, Table[Rectangle[m, {5, 5}], {m, min}]}]


3

Instead of providing the number of contours you want with the option Contours you should provide the values at which you want contours. When using this with a contour plot that uses the same color scheme, you should provide the same values for contours to the contour plot, or you may end up with a mismatch between your legend and the plot. ContourPlot[y, ...


2

A version 10 approach: tnb[g_, t_] := Last@FrenetSerretSystem[g[t], t] func[g_, t_, pc_, s_] := Line[g[t] + # & /@ ((Plus @@ (tnb[g, v] #) & /@ Table[PadLeft[s pc[j], 3], {j, 0, 1, 0.05}]) /. v -> t)] Some test functions: arc[t_] := {-t, t, 1/2 t (8 - t)}; helix[t_] := {Cos[ 2 t], Sin[ 2 t], 0.25 t} f[u_] := BSplineFunction[{-{0.25, ...


6

I've decided to be a bit ornery and render the spiral of Theodorus in an anticlockwise fashion for this answer, for reasons I'll explain later. The following is similar to what Michael did in his answer to a related question: polys = NestList[With[{hyp = Delete[#[[1]], 2]}, Polygon[Append[hyp, Last[hyp] - Normalize[Cross[Subtract @@ ...



Top 50 recent answers are included