Tag Info

Hot answers tagged

37

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 ...


24

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, ...


18

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]}, ...


17

Here's a method based on creating a MeshRegion from the text: text = Style[HoldForm @ Sum[x^2, {x, 0, 10}], 100, Bold]; graphics = First[text ~ExportString~ "PDF" ~ImportString~ "PDF"]; region = DiscretizeGraphics[graphics, MaxCellMeasure -> 5]; image = ExampleData[{"ColorTexture", "Kingwood"}]; RegionPlot[region, Frame -> False, ...


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 ...


12

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 ...


11

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 ...


11

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

It sounds like you might like to use a stereographic projection. xy[ϕ_, λ_] := 2 Tan[(π - ϕ)/2] {Cos[λ], Sin[λ]}; 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 curve, it's automatic and much simpler ...


10

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, ...


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 ...


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[ ...


9

ImageAdd is your friend: image = Import["http://creativity103.com/collections/Graphic/rainbowbars.jpg"]; text = HoldForm @ Sum[x^2, {x, 0, 10}]; img2 = Image @ Rasterize @ Style[text, 100, Bold]; rainbow = image ~ImageResize~ ImageDimensions[img2] ~ImageAdd~ img2 With Pickett's extension for outlining: img3 = ColorNegate[img2] ~Dilation~ 2 // ...


8

"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] ...


8

There is a PlotMarkers option in ListPlot: img = ExampleData[{"TestImage", "Lena"}]; ListPlot[Table[{Sin[n], Sin[2 n]}, {n, 50}], PlotMarkers -> Show[img, ImageSize -> 20]]


8

I think the "ugly thing" might be because texture is interpolated on triangles (demonstrated after), and a quadrangle is only divided into 2 triangles - up-left and down-right. So to solve the problem, we just need a triangulation network with much higher resolution. One way is to use ParametricPlot: ParametricPlot[ Evaluate[tr@{u, v}], {u, ...


8

In general, I don't think it's possible to use Texture directly with the built-in primitives such as Sphere and Cylinder. See also Texture mapping and resizing a sphere primitive in Mathematica. So you have to write your own replacement for those primitives. Since you specifically mentioned the Cylinder, I added the ability to handle Texture to my answer ...


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 = ...


7

Whenever you have an object in a three-dimensional scene that needs to be displayed independently of the lighting conditions, it's a good idea to give that object a Glow. From the docs: Glow is a color component independent of simulated illumination. This is what I use in the definition of gr (last line before Show in the answer linked in the ...


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, ...


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

Using Simon Woods' shadow package this is easy: text = Style[HoldForm@Sum[x^2, {x, 0, 10}], 100, Bold]; image = ImageResize[Import["http://creativity103.com/collections/Graphic/rainbowbars.jpg"], ImageDimensions@Rasterize@text]; shadow[image, text] In the example above I stretched the background to fit the image of the equation. If you want to tile the ...


6

You can set Texture before each polygon t = ImageResize[ExampleData@#, {100, 100}] & /@ ExampleData["ColorTexture"][[;; 6]]; vtc = {{0, 0}, {1, 0}, {1, 1}, {0, 1}}; coords = {{{0, 0, 0}, {0, 1, 0}, {1, 1, 0}, {1, 0, 0}}, {{0, 0, 0}, {1, 0, 0}, {1, 0, 1}, {0, 0, 1}}, {{1, 0, 0}, {1, 1, 0}, {1, 1, 1}, {1, 0, 1}}, {{1, 1, 0}, {0, 1, 0}, ...


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"}]]}]


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}}]}]


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 ...


4

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 ...



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