17

There is a hack that has some added advantages - in particular as a by-product you also get a vector graphics version of your plot that can be resized while keeping all relative sizes at the correct proportions: plot = Plot[x, {x, 0, 10}]; h = First@ImportString[ExportString[plot, "PDF"]]; Rasterize[h, ImageResolution -> 300] The result has all the ...


15

With a bit of spelunking I extracted the following from g = Graphics[{Circle[], FontSize -> 20, Text["x^2+y^2<1", {0, 0}]}, ImageSize -> 72]; Trace[Rasterize[g, ImageSize -> 72, ImageResolution -> 100]] in v.10.0.1. An excerpt from the Trace output 1) At first, the value of RasterSize is extracted from the Rasterize command using ...


13

I had the same problem after switching to Mathematica 10. The issue here is the following: Export uses Rasterize to create the png image. The StyleEnvironement, which is used in Rasterized, cannot be specified as an option but is given by the $FrontEnd object (not by the EvaluatingNotebook[]!). You can change the StyleEnvironement by SetOptions[$FrontEnd, ...


12

Yves showed you how to shave off a factor of 10, and in the following I'll shave off another factor of 10. First, the original code (plus some data of mine to make it work): points = RandomReal[{0, 10}, {1000, 2}]; n = 500; p = .99; g1 = Graphics[{PointSize[1/n], White, g = Point /@ Join @@ {points, points.{{1, 0}, {0, -1}}}, Array[Rotate[g, Pi #/...


11

One way to save memory is to use the multi-primitive syntax for Point (which should also render quite a bit faster)`: coords = RandomReal[{-1, 1}, {1000, 2}]; Point /@ coords // ByteCount Point@coords // ByteCount %/%% // N (*176200 16552 0.0939387*) For your example you simply drop one character to save a whole lot (about 90%) of kernel real estate:...


9

Good question. I believe it is the result of an incomplete attempt to optimize conversion of Raster objects to Image objects; a bug in other words. Note that when the axes are included the output is correct: Image @ Graphics[myraster, Axes -> True] (* v10.0.1 *) Trace of the correct conversion Running a Trace with option TraceInternal -> True on ...


8

I could not get it to work with $FrontEnd, but setting the ScreenStyleEnvironment on $FrontEndSession worked for me. Here text cells get two different backgrounds and font sizes, depending on the environment. ("Printout" is pink and large.) sseOpt = Options[$FrontEndSession, ScreenStyleEnvironment]; SetOptions[$FrontEndSession, ScreenStyleEnvironment -> ...


7

Edit (23/02/15) : V10 & V9 V10 It seems that the new (v10) option ImageFormattingWidth is what you are looking for. In your case, I get the same graphic whatever the size of the window is if I write : Rasterize[ TraditionalForm[ Log[Sqrt[x^2]] (x - x^3)/(y + y^2) + 1/(y - y^2)], "Image", RasterSize -> 800, ImageFormattingWidth -> Infinity] ...


7

Maybe this: icol[r_, c_] := Item[Style[NumberForm[r, {4,3}], c], Background -> GrayLevel[r]]; item[r_Real /; 0 <= r <= 1] := If[r > 0.5, icol[r, Black], icol[r, White]]; Grid[Map[item, RandomReal[1, {4, 4}], {2}], ItemStyle -> "Text", ItemSize -> {5, 5}, Alignment -> {Center, Center}] To add the row and column headers: Grid[ ...


7

You can avoid Item and do this by referencing the Grid positions directly in Background and ItemStyle: SeedRandom[1]; tmp = RandomReal[{0, 1}, {4, 4}]; Now: Grid[tmp, Alignment -> {Center, Center}, Background -> {None, None,Flatten[MapIndexed[#2 -> GrayLevel[1 - #1] &, tmp, {2}], 1]}, ItemSize -> {10, 5}, ItemStyle -> {None, None,...


7

The following workaround can be seen as an alternative to simpler and more reliable (but in some situations not appropriate) workaround suggested by Jens. It is not perfect because in addition to being significantly more complicated it has several limitations due to abundance of bugs in Export-related functionality: ImageSize must be specified in Export ...


7

I tried this in MMA 10.01 (Mac) with a simple example from the documentation: anim = Table[Plot[Sin[n x], {x, 0, 10}], {n, 5}] It doesn't look terrible but I agree that the anti-aliasing is clearly better in MMA (I had previously modified my anti-aliasing quality settings via Preferences/Appearance/Graphics). A possible reason for this is that MMA's ...


7

As Kuba notices in the comment, undocumented FrontEnd`ExportPacket allows conversion of a whole Notebook into plain text: nb = NotebookGet@EvaluationNotebook[]; First[FrontEndExecute[FrontEnd`ExportPacket[nb, "PlainText"]]] "nb=NotebookGet@EvaluationNotebook[]; First[FrontEndExecute[FrontEnd`ExportPacket[nb,\"PlainText\"]]]" But it isn't the whole story. ...


7

Note that when you apply ImageDimensions, or any other image-processing function to Graphics, the Graphics will be automatically Rasterized to an Image. What you see is a change that was made to the default rasterization resolution. Version 12.1 fully supports HiDPI, so some things are rendered at double resolution. They made the decision to choose the ...


6

Rasterization/rendering is done by the front end, not the kernel. Image[Graphics[...]] also does rasterization. The parallel subkernels do not have a front end attached so they cannot render graphics. When a kernel process doesn't have a front end attached and it needs to render graphics (e.g. for exporting), it will start up a front end process in the ...


6

I don't have time for a complete answer at the moment but hopefully this helps. I believe that ImageSize, if specified directly inside Rasterize, overrides the ImageResolution. Observe this behavior when ImageSize is used in Graphics instead: g = Graphics[{Circle[], FontSize -> 20, Text["x^2+y^2<1", {0, 0}]}, ImageSize -> 130]; r = Table[...


6

Use background without labels (with the option GeoBackground -> GeoStyling["StreetMapNoLabels"]) and add the labels as Text primitives: oceanlabels = Text[Style[StringRiffle[StringSplit[ToUpperCase@#["Name"]], "\n"], 24, Gray, Italic, ShowStringCharacters -> False], GeoGridPosition[GeoPosition[#["CenterCoordinates"]], "Equirectangular"]] &...


5

n = 7; mat = Round[RandomReal[{0, 1}, {n, n}], 0.01]; ft = Transpose[{Range[n], Take[CharacterRange["A", "Z"], n]}]; ArrayPlot[ mat, Epilog -> MapIndexed[Text[#1, #2 - 1/2] &, Transpose @ Reverse @ mat, {2}] /. Text[a_, b_] :> Text[Style[PaddedForm[a, {3, 2}], If[a > 0.5, White, Black]], b], FrameTicks -> {ft, ft}, Mesh -> True, ...


5

UPDATE It seems that I found a straightforward way to disable rasterization while preserving the original appearance: the key is to add the ChartBaseStyle -> EdgeForm[Directive[GrayLevel[0.356], Opacity[1]]] option. The offending dot bug (demonstrated below in the "Original answer" section) we steel have to fix separately via post-processing /. {Opacity[...


5

It is doof but it is working (I had the same problem): Export["p5.png", Import[Export["p5.pdf", p5, ImageSize -> 360, ImageResolution -> 1000]], ImageResolution -> 1000] where p5 the name of your plot


5

OK, I'll just put up this work-around - it's not perfect because the scaling of the ticks has never worked properly, to my knowledge: list = {{{10., 5.}, {40., 20.}, {160., 80.}}, {{10., 1.83772}, {40., 13.6754}, {160., 67.3509}}, {{10., 8.16228}, {40., 26.3246}, {160., 92.6491}}}; myPlot = ListPlot[list, Frame -> True, FrameLabel -> {...


5

The width returned by Rasterize is not always correct, as you found out, and since you aren't going to Rasterize before building your tree then the size of the raster graphics is irrelevant in this case. This is the best way to get the size of the text cell (thanks to Sjoerd C. de Vries), {w1, h1} = ImageDimensions@ImageCrop@Graphics@ExpBox[Fooooo/2]; {w2, ...


5

Get the image: i = Import["http://exampledata.wolfram.com/coneflower.jpg"]; Define regions for: the whole image, the window disk, the black dot disk: imRegion = Rectangle[{0, 0}, ImageDimensions[i]] disk1 = Disk[{80, 60}, 40]; disk2 = Disk[{80, 60}, 10]; Window by changing everything in imRegion but not in disk1 Black: windowed = ImageApply[{0, 0, 0} &...


4

UPDATE Starting from Mathematica version 9 one can use comparatively simple workaround suggested by Jens. For previous versions the only known workaround is providing manual Ticks specifications, see below. Original answer This problem is described here as well. Slava Nadvorny suggests using manual Ticks specifications. In this case they will scale with ...


4

Another easy idea: use difference between white and black backgrounds to set alpha channel SetAlphaChannel[#2, ColorNegate@ImageSubtract[##]] & @@ ( Rasterize[ Graphics[{Black, Disk[], White, Disk[{1, 1}/64, 1 - Sqrt[2]/64]}], Background -> #, RasterSize -> 400, ImageSize -> 400] & /@ {Black, White})


4

In your present example the operation that is slow is the rasterization of the Graphics expression. This is implicitly performed by both ImageDifference[target,example1] and ColorConvert[example1, "RGB"]. By pre-rasterizing for example2 you remove this costly step and the ImageDifference is two orders of magnitude faster. If you include the rasterization ...


4

Is rasterization going to make the notebooks smaller? It depends on the specific graphics. The documentation tools in Workbench will rasterize only those plots which actually become smaller in raster form. I have not delved deep into this, but I think a way to make a rough estimate of the size is this: StringLength@Compress@ToBoxes[graphics] StringLength@...


4

What happens if you go to Edit | Preferences | Appearance | Graphics and crank the slider for "Antialiasing Quality" up to highest quality? Also, you might want to consider trying the antialias functions given here and here. Those posts might contain additional helpful information about the topic. When you do this, it's easy to get something like this


4

If we examine the box structure of the output with shift-cmd-e, we can change the value "Tiling" points to. For the input Graphics3D[{StippleShading[], Sphere[]}, Boxed -> False, Lighting -> "Accent"] it's output has boxes Here's a few choices: Edit It looks like we can use the box structure in the initial call: stipple = SurfaceAppearance["...


3

I am the person who originally hit this problem several years ago. Recently Wolfram got back to us with a fix that works for us. It's a slight variation on Alexey's original answer. Export[stringtouse, DeleteCases[ obj /. {_Opacity, p_Point} :> {PointSize[0], p}, _Opacity, Infinity], opts] I bound this up into a little helper function like this. ...


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