Tag Info

Hot answers tagged

27

I'm posting this as a second answer, as it's really a completely different approach. It's also been substantially expanded as of April 25, 2012. While this still doesn't specifically address the question of adding a region, it does plot the countries separately. Of course, each country could be viewed as a region in itself. Our objective is to make a ...


19

This is not a direct response to the question but rather a response to Istvan's comment to FJRA answer. As Istvan points out, the 3D globe has "artefacts like excess polygon-parts". An alternative approach is to use ParametricPlot3D together with a 2D map as a texture. Here's the result. SeedRandom[4]; countries = Table[{ColorData["DarkTerrain"][Random[]], ...


18

You could use a combination of Translate and Scale. Suppose the radii and centres of the circles are given by radii = RandomReal[{.1, .6}, 8]; centres = RandomReal[{-2, 2}, {8, 3}]; Then using the original sphere image = ExampleData[{"ColorTexture", "GiraffeFur"}]; sphere = SphericalPlot3D[1, {theta, 0, Pi}, {phi, 0, 2 Pi}, Mesh -> None, ...


15

Go into the option inspector, and try the different settings for Graphics Options > RenderingOptions > "Graphics3DRenderingEngine and see if that has any effect. Edit This option can be set on a per-graphic basis, say by using Style: AbsoluteTiming[ Rasterize[ Style[Graphics3D[{Opacity[0.1], Sphere[{0, 0, 0}, #] & /@ Range[20]}, ...


12

I don't think you can control the interpolation used by Texture. One option might be to embed the image as a Raster primitive instead. Show[ParametricPlot[{20 + 1.4 x - 40 y, x}, {x, 0, 200}, {y, 0, 1}, BoundaryStyle -> Directive[Purple, Thick], PlotRange -> {{0, 201}, {0, 144}}, Prolog -> {Raster @ Reverse @ ImageData @ a}]] Zoomed ...


11

The main problem here is that you need to include a VertexTextureCoordinates (VTC) in the Polygon for a texture to be applied. However, the rest of the problem is not as simple as it seems. Here's the output of my approach. Below it, I discuss texturing several polygons belonging to the same country, according to their timezone. You can also skip that and ...


10

Well, you’ve clearly established that they’re no set–subset relationship between SchematicPolygon and Polygon. One can only speculate as to why that is, but the fact remains that this behaviour of Polygon is documented: “Main boundaries [i.e. Polygon] exclude entities such as outlying islands and dependencies.” It is desirable at least for some purposes ...


10

This example is from the documentation for Texture in Mathematica version 8: With[{vc = Transpose[ Rescale /@ Transpose[First[CountryData[#, "Coordinates"]]]]}, Show[CountryData[#, "Shape"], ImageSize -> {{100}, {100}}] /. {RGBColor[__] :> Texture[ImageReflect[Image[CountryData[#, "Flag"]], Top -> Right]], Polygon[a_] :> ...


10

You can use the raster image produced by MatrixPlot as Texture directive if you construct Cylinder using ParametricPlot3D or ContourPlot3D. mplt = MatrixPlot[Table[Sin[x y/100], {x, -10, 10}, {y, -10, 10}], ColorFunction -> "Rainbow", Frame -> False, ImagePadding -> 0, PlotRangePadding -> 0] ParametricPlot3D ...


10

It sounds like you might like to use a stereographic projection. xy[\[Phi]_, \[Lambda]_] := 2 Tan[(\[Pi] - \[Phi])/2] {Cos[\[Lambda]], Sin[\[Lambda]]}; Here is a cubic with a free parameter (for fun): cubic[{x_, y_}, b_] := y^3 - b x y + 4 x^3; For the sphere, use SphericalPlot3D of course. Although you could resort to ParametricPlot3D for the cubic ...


9

I made a program of this kind before and the most efficient solution I found was Cuboid. Or perhaps it was the best-looking solution. The rendering code is: render[stack_, iterations_, color_, thickness_, overlap_] := Module[ {center, interval, width = Length[stack[[1]]]}, interval = 2. \[Pi]/width; Last@Reap[Do[ Sow[Rotate[ ...


8

Perhaps something like this? p = Plot[x^3/9, {x, -3, 3}, PlotStyle -> Thickness[0.01], Filling -> Axis, AspectRatio -> 1, ImageSize -> 500, BaseStyle -> {FontFamily -> "Calibri", 30}, AxesStyle -> Thick]; With[{k = 3}, SphericalPlot3D[1, {theta, 0, Pi}, {phi, 0, 2 Pi}, Mesh -> None, Boxed -> False, Axes -> False, ...


7

I noticed an example in the document of Texture which used the alpha channel. So I think a disk-shape primitive may be simulated to a limited degree by mapping the image img, which has been set to 100% transparent outside of the circle, onto a rectangle-shape Polygon. My code: img = Rasterize[ DensityPlot[Sin[x] Sin[y], ...


7

kguler's answer is perfectly correct but I thought it worth mentioning that rescaling the Polygon itself is not necessary, only the vertices: gp := Graphics bill = ExampleData[{"TestImage", "Lena"}]; rawpoly = {{1, 0}, {.5, .86}, {-.5, .86}, {-1, 0}, {-.5, -.86}, {.5, -.86}}; poly1 = Rescale[rawpoly, {-1, 1}, {0, 1}]; g1 = ...


6

Does this work? lena=ExampleData[{"TestImage", "Lena"}]; poly1 = {{1, 0}, {.5, .86}, {-.5, .86}, {-1, 0}, {-.5, -.86}, {.5, -.86}}; scldpoly1=Rescale[poly1,{-1,1},{0,1}]; g1 = {Texture[lena],Polygon[scldpoly1,VertexTextureCoordinates -> scldpoly1]}; Graphics[g1] or something like: poly2 = {{-.5, -.5}, {.5, -.5}, {.5, .5}, {-.5, .5}}; ...


6

u = {x, x^3, 0}; v = {0, 0, z2}; l = (u - v) t + v; w = l /. Solve[xs xs + ys ys + (zs - 1)^2 == 1 /. Thread[{xs, ys, zs} -> l], t][[2]]; Manipulate[Show[ ParametricPlot3D[{Cos[u] Sin[v], Sin[u] Sin[v], 1 - Cos[v]}, {v, ArcCos[1 - z1], 0}, {u, 0, 2 Pi}, PlotStyle -> {Opacity[.3], FaceForm[Red, Yellow]}, Mesh -> False, ...


5

Not too hard. a = Image[Table[If[EvenQ[x + y], 1, 0], {x, 50}, {y, 50}], ImageSize -> Large]; Graphics[{Texture[a], Polygon[{{1, 0}, {0, Sqrt[3]}, {-1, 0}}, VertexTextureCoordinates -> {{1, 0}, {0.5, 1}, {0, 0}}]}]


5

"Antarctica" is part of CountryData, but it is not returned by CountryData[All], and it's only returned by CountryData["Continents"]. If you want quick graphics (including country borders) you should use: Graphics[{EdgeForm[{Green, Thin}], CountryData[#, "SchematicPolygon"] & /@ Flatten@{CountryData[All], "Antarctica"}}, ImageSize -> 400] ...


5

As a generalisation of kguler and Verbeia's answers, you could do something like this rescale[poly_] := Module[{xrange, yrange, ratio, midp}, xrange = Through[{Min, Max}[poly[[All, 1]]]]; yrange = Through[{Min, Max}[poly[[All, 2]]]]; midp = {Total[xrange], Total[yrange]}/2; Rescale[(# - midp) & /@ poly, Max[yrange[[2]] - yrange[[1]], ...


5

Like RM, I've not been able to texture a Disk primitive. We can create a textured disk using ParametricPlot, however. ParametricPlot[{r*Cos[t], r*Sin[t]}, {r, 0, 1}, {t, 0, 2 Pi}, Mesh -> False, BoundaryStyle -> None, Axes -> False, PlotStyle -> {Opacity[1], Texture[ExampleData[{"ColorTexture", "LightCherry"}]]}]


4

I'm not quite sure why this happens, but it does look like the natural lighting isn't applied correctly when exporting to EPS or PDF. It does work when I export to PNG. However, for your purposes it's not too hard to work around that: just give the 2D part of your plot a glow of its own which overrides any lighting: gr = Graphics3D[{Glow[White], ...


4

My fallback method for the moment is the following: approximate a circle with a polygon, fill the latter with the texture and finally conceal the angular edge with an overlaid Circle. If the whole image is small, the number of nodes of the polygon can be further reduced. One annoying sideeffect is though that the Circle is not antialiased... img = ...


4

Using a combination of nearest resampling and a large size (e.g. 2000 pixels) should do the trick. a = ImageResize[Import["http://i.imgur.com/PiLKV6S.png"], {2000}, Resampling -> "Nearest"]; Show[ParametricPlot[{20 + 1.4 x - 40 y, x}, {x, 0, 200}, {y, 0, 1}, BoundaryStyle -> Directive[Purple, Thick], PlotRange -> {{0, 201}, {0, 144}}, Prolog ...


3

I've had problems when pushing images above a certain size. For example, it's ok at 1500: DensityPlot[Sin[x] Sin[y], {x, -4, 4}, {y, -3, 3}, ColorFunction -> "SunsetColors", ImageSize -> 1500] But pushing it too far: DensityPlot[Sin[x] Sin[y], {x, -4, 4}, {y, -3, 3}, ColorFunction -> "SunsetColors", ImageSize -> 2000] While I ...


3

Try: Graphics[{EdgeForm[White], {{Texture[Image[CountryData[#, "Flag"]]], Polygon[First@First[CountryData[#, "Polygon"]], VertexTextureCoordinates ->Transpose[ Rescale /@ Transpose[First@First[CountryData[#, "Polygon"]]]]]}} & /@ {"Venezuela", "Colombia"}}] which gives


3

If you click the disk and check Drawing tools from the menu there is only color fill options no texture options available. Also see Heike's related answers: in math group or mathematica group mainly she states "Applying Texture to a disk directly isn't possible, but you could for example use RegionPlot with the TextureCoordinateFunction option, e.g" img = ...


2

Here's an extension of Silvia's method of setting an alpha channel in the texture. The alpha mask is obtained directly from the shape using Rasterize, allowing the code to work with ellipses, rectangles, etc. img = Rasterize@ DensityPlot[Sin@x Sin@y, {x, -4, 4}, {y, -3, 3}, ColorFunction -> "BlueGreenYellow", Frame -> None, ImageSize ...


1

Without knowing exactly how you want to define your projected function in terms of the spherical coordinates, I'll just make up a definition and use the following, based on this answer by Vitaliy Kaurov: f[θ_, ϕ_] := SphericalHarmonicY[2, 1, θ, ϕ] With[{thetaMin = .8}, SphericalPlot3D[1, {θ, thetaMin, Pi}, {ϕ, 0, 2 Pi}, ColorFunction -> ...


1

Instead of using ArrayPlot[], one might want to use Image[] directly to produce the textures. For instance, here is the CA texture: BlockRandom[SeedRandom[42, Method -> "MersenneTwister"]; (* for reproducibility *) ca30 = CellularAutomaton[30, RandomInteger[{0, 1}, 100], 30];] (* Image[]'s convention is the reverse of ArrayPlot[]'s *) tex = ...



Only top voted, non community-wiki answers of a minimum length are eligible