Note: This discussion started here: Wikipedia:Graphics Lab/Illustration workshop. There is a signature icon on the editing toolbar of user talk pages such as this one. Unlike on user non-talk pages and subpages.
Can you make an SVG map where one can update it just by pasting in a list of states with minimum wages? For example by copying this simple list for 2023:
@Timeshifter: will see if I can get some help from someone who knows SPARQL better than me. Also it needs the Wikidata info on US states to have the per capita incomeminimum wage - properties added. Shyamal (talk) 03:58, 11 March 2023 (UTC)[reply]
@Timeshifter: Can you please read the documentation of the Graph extension Map mode and do a little research e.g. [1] and [2] to see if there's an existing US states map mode? If so, I can set it up for you. Cheers, cmɢʟee⎆τaʟκ10:55, 8 March 2023 (UTC)[reply]
cmglee. I had forgotten about that thread about a different type of US map. I wonder if there are US base maps now for this template. That is an old thread. Much later I found this non-template map elsewhere and uploaded it:
Am I imagining that there are plug-and-play SVG maps that are easily updated by pasting in a text list? I thought they existed. I have done a lot of editing of tables, and see various state and country lists that have data that would be more useful if the numbers were on the map for each state or country. Especially when combined with a color bar legend. I edit Help:Table and Help:Sortable tables, and so I know how to convert the data from a column to a text list. With the state or country names to the left of the data. So a multi-purpose USA SVG map could be used for many topics: Minimum wages, cumulative Covid death rates, incarceration rates, rate of uninsured, and much more. With the data on the map. Not just a color bar legend, and coloration of states or countries. --Timeshifter (talk) 20:23, 8 March 2023 (UTC)[reply]
It's actually not too hard to make a blank map in which each state can be assigned a colour, but it will require the blank map users to do the colour interpolation (i.e. assigning the appropriate colour between 0% and 100%) themselves. A trick I could use is to draw each state twice, the underlayer in the colour corresponding to 0%, and the overlayer in the colour corresponding to 100% but with the appropriate percentage opacity. It would work for simple percentages, but if it's interpolating between a minimum and maximum value, the user must calculate the percentages to use. The data to be entered by the user will look something like this:
(the number after <text, and the fill-opacity value – if the state is to be greyed out, an invalid xlink:href can be specified e.g. xx). The font size can be set to avoid overly large text strings overrunning.
cmglee. Thanks!. Anything that simplifies the process is good. The main thing is to have one location in the SVG file data where this list resides. Your list or eventually just a simple list. Or maybe a comma-separated values list.
cmglee. I am just trying to find any way to easily update US maps that need regularly updated data, and have a color bar. I'll take any extension I can get at this point. I googled, and don't think Paint.net does SVG saves. Not sure.
Can you tell how OWID is updating their SVG and PNG maps so often:
I have edited SVG files by converting an SVG file to a text file by changing the extension. Then I edit with a text editor such as Notepad++. Then I add back the SVG extension to look at it. --Timeshifter (talk) 07:40, 10 March 2023 (UTC)[reply]
That's great – as you're comfortable editing text files in Notepad++, I'll make a human-editable SVG with comments to ease populating data.
Shyamal and cmglee. I am willing to abandon range coloration for now. First I am looking for a way to paste in the wages all at once. Maybe into a simpler template. Here is another wages list below. This time the wages are first. It is very easy and fast to create these lists. See User:Timeshifter/Sandbox187. It now has both lists.
List. 2023 wages first.
2023 State
$7.25 Alabama
$10.85 Alaska
$13.85 Arizona
$11.00 Arkansas
$15.50 California
$13.65 Colorado
$14.00 Connecticut
$11.75 Delaware
$11.00 Florida
$7.25 Georgia
$12.00 Hawaii
$7.25 Idaho
$13.00 Illinois
$7.25 Indiana
$7.25 Iowa
$7.25 Kansas
$7.25 Kentucky
$7.25 Louisiana
$13.80 Maine
$13.25 Maryland
$15.00 Massachusetts
$10.10 Michigan
$10.59 Minnesota
$7.25 Mississippi
$12.00 Missouri
$9.95 Montana
$10.50 Nebraska
$10.50 Nevada
$7.25 New Hampshire
$14.13 New Jersey
$12.00 New Mexico
$14.20 New York
$7.25 North Carolina
$7.25 North Dakota
$10.10 Ohio
$7.25 Oklahoma
$13.50 Oregon
$7.25 Pennsylvania
$13.00 Rhode Island
$7.25 South Carolina
$10.80 South Dakota
$7.25 Tennessee
$7.25 Texas
$7.25 Utah
$13.18 Vermont
$12.00 Virginia
$15.74 Washington
$16.50 Washington, D.C.
$8.75 West Virginia
$7.25 Wisconsin
$7.25 Wyoming
I can do column editing in freeware Notepad++ or freeware NoteTab Light. Notepad++ is better since it is unicode. I would like to copy the wages column into either one of your methods, and end up with a map with wages for each state. Instantly. No range coloring. Just black text on a pale color. We can do range coloring when we find a way or tool to quickly give opacities or colors for each value (wage) in the list. Then I could do a column paste for that too. --Timeshifter (talk) 13:37, 12 March 2023 (UTC)[reply]
I was going to give you a Google Sheet into which to paste in your data and from which to copy the lines to put in the SVG, but I first need the states listed by USPS 2-letter abbreviations not state name. cmɢʟee⎆τaʟκ13:52, 12 March 2023 (UTC)[reply]
cmglee. That is a perennial big problem. Unfortunately, the 2-letter abbreviations end up in a different alphabetical order than the full names. So simply pasting over the alphabetical full-name column with the alphabetical 2-letter column does not work.
I have not found a tool to quickly convert from one to the other. I suggest using the full names in the template. It would make things a lot easier. Very few state tables on Wikipedia use the 2-letter abbreviations.
Copying and pasting a column from a table is easy in the visual editor (VE). See Help:Table in the VE section at the end. Even new editors can figure it out fairly quickly.
But asking them to also convert to 2-letter abbreviations is another level of skill most won't want to deal with. Even if they do they are likely to forget to alphabetize the 2-letter column. That can't be easily done in the visual editor. They have to use a spreadsheet, and then copy it back to Wikipedia. --Timeshifter (talk) 14:19, 12 March 2023 (UTC)[reply]
I can hardcode the order in the spreadsheet, if it can be assured that the data is always in the order you've given. Is that satisfactory? cmɢʟee⎆τaʟκ17:13, 12 March 2023 (UTC)[reply]
cmglee. I can't assure that because sometimes the state lists for various topics include DC or not. Or it is listed as District of Columbia, or Washington, DC.
And eventually you may do additional spreadsheets for countries. 3-letter codes are used for them in some databases. I hate them, and I hate the 2-letter codes for states in databases. Because there is no easy way to transfer that data to Wikipedia tables correctly. Same alphabetization problems messing up the order. Same problem of converting to full names.
I can't easily copy and paste the latest year to the Wikipedia country table which also has previous years. Even using full names. Country names change in databases. Imagine in addition trying to decipher 200+ country codes and their order.
I have made various mistakes dealing with multi-year tables. Or wide tables with many columns. For example: List of countries by incarceration rate. One editor insisted on combining multiple columns in one table instead of using multiple tables as before. But the data comes from different pages on the same website. So one has to be very careful of name changes, deletions, additions, etc.. It is difficult enough with full names. And the mistakes are sometimes not discovered for a long time. That means people are using mixed up data. That happened here: List of countries by total health expenditure per capita. An anonymous editor found a bunch of mistakes of mine in Feb 2023. See diff.
@Timeshifter: Re US "state" names, even full names have variations e.g. Washington, D.C., DC, D. C., District of Columbia etc. Without implementing something like Hamming distance, it's difficult to associate the data with the diagram. At least USPS abbreviations are consistent.
Country names are even worse, as they have even more variation.
Without solving this issue, I don't see a simple automated way to do what you want, whether it's using a script, spreadsheet, Wikidata, Maplink or Graph extension.
Do ping me again if you manage to work around this problem.
@Timeshifter: I thought you wrote that the state names in the data are subject to variation. https://stackoverflow.com/a/5590014 discusses the same issue except that some states may be missing in the data. This is especially problematic if West Virginia is presented as, say, W.Virginia and Virginia itself is missing, as most algorithms will consider W.Virginia more similar to Virginia than West Virginia.
Also may I suggest moving this thread somewhere else (unsure where is best) as it's getting unwieldy and others having it on their watchlists are needlessly spammed. Cheers, cmɢʟee⎆τaʟκ04:33, 13 March 2023 (UTC)[reply]
cmglee. Here are the names for US states, territories, etc. on Wikipedia:
cmglee. I don't understand what you need to do, and the technical info you linked to went way over my head. And I now don't know exactly what you mean by "hardcode the order". But if we decide on the accepted naming, then I assume that goes a long way in helping this work. --Timeshifter (talk) 13:35, 13 March 2023 (UTC)[reply]
in which one can paste under INPUT the data you shared. Copying the lines generated under OUTPUT and pasting it in template_map_of_usa_states_and_dc.svg gives the image on the right.
Feel free to play around with the spreadsheet (but don't change the formulae unless you know what you're doing!)
cmglee. I think I already messed it up. I don't know how. I can't get back to what you had. Even when I sign out of Google. I may need to close all my windows to get rid of all the cookies.
How do I get to a blank form that I can paste into?
I would like to get rid of the dollar signs ($) on the map. Instead, the caption can say: "Map of US minimum wage by state 2023, in dollars"
I would like to reverse the min and max colors. So that the reddish color matches the political situation of the states that keep minimum wages low. :)
The 2 main colors are good because black text works adequately on both of them.
Cmglee. Thanks for the update. Maybe create another sandbox version with a reset button. And no ability to edit the Google Doc. Users will only be able to use it, not change it. I would like to play around with it. And link to some help info on a Commons subpage of the template. I and others can help fill out the help page.
I forgot that the map needs to have the date of Jan 1, 2023 on the map. On this model:
Cmglee. On map and in above collapsed lists: $5.15 changed to $7.25. Federal minimum wage is actual wage in those states. See List of US states by minimum wage. Federal wage supersedes lower state minimum wages.
I also changed the map caption to "State minimum wages, in dollars. Jan 1, 2023". Because minimum wage will change on certain dates in the year. So viewers see a dated map and know what they are getting.
I uploaded the corrected map to both file locations. So the up-to-date map is now showing in multiple articles, etc..
I believe the file with 2023 in the file title should be deleted (linked below). Normally, the date is not put in the file name, because the file will be updated yearly. I can put a delete request tag on the file.
Irfanview says there is an SVG syntax error in the old and new maps, and won't show me the maps. Firefox shows me the maps without any problem.
Oops. The colors are now wrong since I did not redo the adjusted list in Google Docs. Google Docs is not working right for me. I am able to paste in the corrected list. But no result is shown. By result, I mean the code to paste into the map SVG code in the top section. --Timeshifter (talk) 05:43, 14 March 2023 (UTC)[reply]
I'm unable to do what you wanted earlier (reset button etc) in Google Sheets. Ask the computing reference desk if you need help.
Cmglee. I updated all the state lists on this page and in the sandbox.
I also played around with the free choropleth map tool at Datawrapper.de but was never able to get the data onto the map. I was able to paste in the data list. But it never showed on the map.
Have been reading on palettes that are better for color blind:
https://www.datylon.com/blog/data-visualization-for-colorblind-readers - " So if you’re aiming to create a color blind-friendly palette try to use only two basic hues: blue and red (orange and yellow will also fit). The other colors should be made out of these two hues. All the variations can be made by using different saturation or lightness of the basic color."
I have experimented with various shades of those colors. It is easy to plug in to the SVG since it requires only entering 2 color codes or names. The opacities list is not changed. The main thing is to find light enough shades that black text is still visible against that color backdrop.
Re colourblindness, my aim is to support deuteranomaly which should then satisfy ~95% of the population. As far as I understand, not requiring red-yellow-green discrimination is sufficient. Adding some blue to greens e.g. #009966 also lets it be used with red, as on traffic lights.
Glad you like my technique of using fill-opacity to linearly interpolate between two colours which can be easily changed.
It's certainly better to have a bitmap instead of not having an image, but for non-photographic or topographical images especially with text, I believe Wikipedia recommends vector images.
@Timeshifter: Sadly that's not possible as the SVG doesn't actually specify what colour it is: it just draws one colour, and the other over it with some opacity.
A common device used in subtitles, however, is to outline the text in a contrasting colour so that it can be read against (almost) any background, as in this graphic. Will that do? cmɢʟee⎆τaʟκ14:14, 24 March 2023 (UTC)[reply]
Cmglee. Yes, that would be great! I had forgotten about that method.
In fact, I see that method also used on the Datawrapper map. Most noticeable when a state name crosses both a dark and a light color. --Timeshifter (talk) 14:49, 24 March 2023 (UTC)[reply]
Changed end colors and outlined text
I've done the above using an SVG filter, and also changed the end-stop colors so that larger values are more intense (darker in this case) as per usual illustrative convention. cmɢʟee⎆τaʟκ05:58, 25 March 2023 (UTC)[reply]
Cmglee. It is correct. See List of US states by minimum wage. A consistently good reference from the main table on that page is this one from the Dept. of Labor:
Is it possible that the template could use white text for all opacities above a certain number? It would be nice if there was a spot in the SVG code where I could enter that number. Then I could experiment with different color palettes and opacity white-text numbers before uploading.
The current 2-tone text is not enough contrast with the dark background colors in my opinion. Maybe using a bright white text outline that is wider would help. That would help even if the opacity method above is implemented to get white and black text. Because some state names overlap contiguous states with different background colors. And white text could have a black outline.
I found a graphing template that allows pasting in of lists. See:
The last one I fixed some text overlap problems by adding Liberation Sans to the font family.
Anyway, I am wondering if any of the template's list capability can be used by you. The lists are pasted at the bottom of the SVG code. --Timeshifter (talk) 04:35, 26 March 2023 (UTC)[reply]
It will require rearchitecting the SVG as the state names are drawn in a different place from the values. Additionally, the callouts should be in black regardless of their values. Lastly, I think it is more consistent to have all the labels the same colour, and use the outline trick to distinguish them from the background. As such, I'm disinclined to implement it.
If you wish to experiment with the outline width, edit the lines
and increase either or both the values 0.5 and 2 (the former makes the transition smoother and the latter sharper). Be sure to generate a thumbnail of the expected size on Wikipedia as the rendering on browsers differs from the rsvg one. If you have further questions on this, please ask on Wikipedia:SVG_help.
commons:template:SVG Chart is a clever hack of templates, though I think Toolforge is more appropriate for such a tool than templates. A good tool is Parliament Diagrams. Nevertheless, drawing a line graph is very different from a choropleth map. Effort is much better spent adding a US states basemap to Template:Graph:Map.
Cmglee. Thanks for all the info and help. I don't have a clue about Template:Graph:Map. I looked at the examples on that page, and they are not what I want. I want a non-interactive image I can copy elsewhere. Not just for Wikipedia. I want US maps with the date and state names on the map.
I did not see any examples with data or names on the map. If they exist, I guess they could be used elsewhere by doing a screenshot of the map and making a gif or png image of it. I could go for that. That is basically what OWID does. They make interactive maps, and also have non-interactive SVG or PNG maps available via download.
I did a lot of experimentation with the text outlines on your template. Nothing was really satisfying. To get enough clarity and legibility with a wide color palette (very dark to very light colors) I had to make the white outline wide enough. I succeeded at that. I made many variations, and compared them. With my preferred ones too much of the map is taken up by the text and data. It overwhelms the map. It's like using a very large bold font on a map. Plain white text on dark areas is much better. Plain black text on light areas is much better.
I can ask around for more help. This is wearing me out (health and time). So I appreciate now all the work you must have done to get to this level of skill. I wrote large parts of Help:Table and Help:Sortable tables over the years. I wrote those parts with newbies in mind. People shouldn't have to suffer to get stuff done. A lot of this stuff can be made much more accessible. Your template is a great step in that direction.
I need to find an expert on colorblindness to tell me what 2 colors to use on your template once I figure out how to get white text for dark colors. I have looked at a few pages on color blindness, and haven't seen anything specific to a color gradient based on 2 colors and opacity. --Timeshifter (talk) 01:54, 28 March 2023 (UTC)[reply]
Your requirements are fair. To provide such flexibility, I'd recommend creating a tool on Toolforge. I've no experience in creating one, but could refer you to the expert @Magnus Manske: he has created many useful tools.
Well done documenting Wikimedia features. Wikimedia could certainly improve accessibility to people less technically inclined.
I'd sure like some authoritative guidelines on colour-blindness as I find conflicting info on the Web.
So green was removed. I think I read somewhere that green is not a good color for some of the colorblind.
From previous post:
https://www.datylon.com/blog/data-visualization-for-colorblind-readers - " So if you’re aiming to create a color blind-friendly palette try to use only two basic hues: blue and red (orange and yellow will also fit). The other colors should be made out of these two hues. All the variations can be made by using different saturation or lightness of the basic color."
I think green without some blue (somewhat cyan) shouldn't be used with red to yellow shades as the only distinguishing feature (dark red and light green together are fine as luma is a distinguishing feature). I know I'm sometimes guilty of this! I use http://color-blindness.com/coblis2 to check whether a combination is acceptable. Cheers, cmɢʟee⎆τaʟκ05:14, 30 March 2023 (UTC)[reply]
Cmglee. Interesting. I am beginning to understand that tool. Have to drag the map, and zoom in and out to use the tool effectively. The green shaded areas change for some colorblind people making areas next to it less distinguishable. Going from "green weak" to "green blind".
I thought nothing happened when I clicked on the 3 choices for lens. Only after going to this page many times did I notice the circle that can be moved around. Because I had no reason to run my mouse around on the map until I learned I could drag the map around. People create these great tools, and then don't explain them for newbs like me. So the tool gets far less use. Short tips are needed right on the tool page. Since people are often coming directly to the tool page as I did.
I noticed a change of yours by comparing svg page sources here via revision diffs:
I intend to use that template page of yours to create a bunch of US maps using lighter colors. Then I can go ask for help with getting white text on dark colors. Since people will see that it matters for more than just a map or two.
What are the best 2 end colors (not too dark for black text without text outlining) you have found so far to use for the end colors? Can we incorporate those 2 into the template? I would like to point people to this template for their US maps. I can help with the template docs.
I picked a very light pastel red (#faf5f5) as an end color, along with skyblue end color. "Misty rose" is a little darker pastel red. I can't get the coblis page to work for me anymore. It accepts my uploads, but does not show them. --Timeshifter (talk) 03:42, 31 March 2023 (UTC)[reply]
Yes, the lens feature is quite useful. I suppose these tools are written by engineers with little formal training in user experience (including myself). If it doesn't work anymore, try refreshing the page, opening a new tab or window, or restarting the browser or your device.
I think the plain text (no outlines) is much more legible with my preferred end colors. I think the problem is that the outlining is removing the sharp edge from the black text. Maybe there are some totally free, sharp outline fonts that Wikimedia could put into the MediaWiki software. But that is research I don't have the time or health for.
I compared the SVG code between the map (#ffcccc #33c5ea) with outlined text and without. See diff.
Is there any problem with the SVG code I am using for the non-outlined map?
What do you think of a second template map without outlined text?
I was thinking of starting it, but it needs to stay up to date in its ability to work with your Google doc.
I will create more US maps, and link to them from that template as examples.
I can write up some simple how-to info on both template pages on how to use the Google doc. I do how-to info already on many file pages in order to explain sourcing, cropping, adding text, adding borders, and much more.
2 templates allows work to continue on maps with outlined text, and on maps with plain text. The plain text template might eventually end up with both black and white text. People can work on the SVG code on their template of interest.
A way to have a sharp outline without SVG filter is to draw the text with a white stroke, then draw it again without a stroke. Without the latter, the stroke intrudes into the character, making it too thin. It will require changing the structure of the SVG; as I previously wrote, the state names and numeric values are drawn in different places.
I don't understand "Is there any problem with the SVG code I am using for the non-outlined map?"
Having a second template complicates maintenance. You could just put in a comment for the template user to simply delete the line
But that assumes a bright monitor. I, and many others, turn down the brightness level on our monitors in order to avoid eye pain and strain. So that further darkens the cyan with the overall grayness contributed by a dimmer monitor. I have a system tray tool I can click to go to 100% brightness, or click again to go down to a lower level of brightness I have chosen. I choose 80%. See the freeware:
I flip it up or down depending on the web page, or whether I am watching a video (100%).
One template is definitely better than two. And I was surprised that removing only one line of code could remove the outlined text. I think that is easiest enough that most newbs could do it if desired.
I was wondering about the SVG in the outlined-text map versus the SVG found in the same map with regular text. See sandbox diff.
There is obvious added SVG for the outlined text.
But I was particularly wondering about this:
class="overlay"
It is not found in the SVG for the outlined text map.
I guess this is a good reason not to have dual tracks for outlined text and regular text. Things get confusing.
Otherwise people may try to update the urban population map, and not pay attention to how it should be done. And search engines can not find that map when the template name is different from what the map is about. The urban population map would be better with its own filename. --Timeshifter (talk) 23:28, 7 April 2023 (UTC)[reply]
Yes, CSS allows one to "style" parts of a web page (including SVG and Wikipedia pages) at different granularities. The "text" line applies the specified filter on all text elements.
The "class" bit is an obsolete remnant of my experimentation. As it's no longer in use, it may be deleted (though doesn't cause any harm if not).
Please feel free to delete the *2023.svg file. I made it to not overwrite the original until it was approved.
I prefer a realistic example instead of just numbers to show editors how it can be used. I intentionally used an example with percentages to avoid the issue of calculating the opacities.
As you're much better at writing documentation (than I am), can you please write a blurb to explain to other editors how they should edit the file?
cmglee. OK. I will start working on the how-to info. I am working on multiple projects though, with time and health constraints. Feel free to add info yourself too. I will clean it up. --Timeshifter (talk) 15:22, 9 April 2023 (UTC)[reply]
cmglee. Can you revert back to the map with the regular text here?:
Apparently, there are no revert links for people who haven't uploaded any versions of the map. I see revert links on the ..2023.svg map where I have uploaded a couple versions of the map.
Your colors show more distinction between New England states.
Someone did an SVG validation check on the template and found a couple errors. Link is found at the bottom of the file description on the template page:
The "in2" errors can be ignored. Most browsers (and rsvg) understand that the current image buffer should be operated on if an input buffer is not specified. cmɢʟee⎆τaʟκ12:41, 10 April 2023 (UTC)[reply]
I reverted to my preferred map. I can see revert links here:
I thought you previously wrote that you preferred the pink–blue scheme. Personally, I find the orange–cyan scheme too intense, specifically orange for low values especially after 5.15 changed to 7.25, as a "bright" colour should be used as an accent rather than dominate the whole map. Cheers, cmɢʟee⎆τaʟκ09:09, 11 April 2023 (UTC)[reply]
That's assuming a bright white background. I can't read the text on the darkest blue color with one of my slightly dimmed monitors. It's not enough contrast when viewing the map in articles at the sizes used in these articles:
But it is much easier to read the black text on the orange background at article sizes for some reason on my slightly, or even more than slightly dimmed monitor. Maybe because the dimming makes the blue background darker versus the orange background. The blue background is starting darker to begin with. --Timeshifter (talk) 18:40, 13 April 2023 (UTC)[reply]
Yes, I much prefer cyan to orange with high values being orange. Now the Pacific states, northeast and DC stand out. Let's keep this scheme for future maps. Cheers, cmɢʟee⎆τaʟκ07:38, 15 April 2023 (UTC)[reply]