Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • svg layers disappearing

    Hi all,

    I'm hoping for some advice in trouble shooting. I'm having trouble export svg files - my layers keep disappearing (I think). I tried to create an example but it worked perfectly, so now I'm just confused. The below code creates a histogram in an svg file that displays fine on Word.

    Code:
    sysuse lifeexp
    
    twoway (histogram lexp if region == 2, fcolor(ebblue) frequency) ///
    (histogram lexp if region!=2, fcolor(purple%50) frequency)
    
    graph export "$graphs/mygraph.svg", replace
    However when I try the below code, using real data (22K obs, 'dob)_y' is a double type) , I get empty layers, as per the image below. (Note this is an annotated screenshot because I don't think I can upload .svgs files.) Even when I 'save as' from the graph window, where my graph displays perfectly, I get the same thing. There is a very small amount of data in the bottom left corner - I was wondering if somehow I had set things up to have an enormous graph area, but I'm not sure how to check for that. I'd be grateful for any troubleshooting advice.

    Code:
    twoway (histogram dob_y, fcolor(ebblue) frequency ) ///
    (histogram dob_y if mar==1, fcolor(purple) frequency )
    graph export "$graphs/freq_byAge.svg", replace

    Click image for larger version

Name:	svg.PNG
Views:	1
Size:	8.4 KB
ID:	1537655


    Attached Files

  • #2
    I wonder what happens with the graph under .gph extension.
    Best regards,

    Marcos

    Comment


    • #3
      Thanks Marcos. It's doing just what it's meant to. This is what the graph looks like in the graph window or if I open it up with the .gph extension:

      svg.PNG


      And then when I 'save as' an svg:

      Click image for larger version

Name:	svg.PNG
Views:	1
Size:	5.1 KB
ID:	1538070


      Attached Files

      Comment


      • #4

        The SVG file should open in all modern web browsers.

        ​​​​​​​You can validate the SVG file using https://validator.w3.org/#validate_by_upload.

        ( Follow the advice in the FAQ # 11-12 )

        Comment


        • #5
          Hi Bjarte,

          I'm using Stata 15. The problem is not opening the svg file - the problem is that Stata doesn't compile it properly. I end up with a valid svg file, but it is different from the figure in the graph window. I think it is a bug, and I was hoping there is a way around it.

          Susan


          Originally posted by Bjarte Aagnes View Post
          The SVG file should open in all modern web browsers.

          You can validate the SVG file using https://validator.w3.org/#validate_by_upload.

          ( Follow the advice in the FAQ # 11-12 )
          Last edited by Susan Wilson; 24 Feb 2020, 20:56.

          Comment


          • #6
            If Stata is updated and the rendering of the SVG in a browser or SVG editor show the same as MS Word; report the problem to [email protected].

            Comment

            Working...
            X