Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#3122 closed enhancement (fixed)

d.legend.vect: possibility to change text of displayed labels and select labels to show/not show

Reported by: veroandreo Owned by: grass-dev@…
Priority: normal Milestone: 7.4.0
Component: Display Version: unspecified
Keywords: d.legend.vect, gsoc2016, cartography Cc:
CPU: Unspecified Platform: Unspecified

Description

Hello,

I've been testing the new d.legend.vect and it is great :)

However, I found that it would be even better if one could change the label displayed. Not always the name of the vector map is the best option, especially if one is displaying for example only one category of an attribute. For instance, I have presence/absence points and only want to display presence points. I'd like to be able to tweak the label to be "presence" instead of the name of the vector map.

Also, sometimes one has boundaries of countries or coastlines that should go on the map but doesn't need to have a label in the legend. If one disables the display of the map, it disappears from the legend, that's fine. But it would be great to be able to choose which items should have label and which shouldn't (but still be displayed).

Thanks a lot!

Attachments (1)

d.vect.legendflag.diff (1.5 KB ) - added by mlennert 8 years ago.
patch to add flag to not add layer to legend

Download all attachments as: .zip

Change History (15)

in reply to:  description ; comment:1 by annakrat, 8 years ago

Replying to veroandreo:

Hello,

I've been testing the new d.legend.vect and it is great :)

However, I found that it would be even better if one could change the label displayed. Not always the name of the vector map is the best option, especially if one is displaying for example only one category of an attribute. For instance, I have presence/absence points and only want to display presence points. I'd like to be able to tweak the label to be "presence" instead of the name of the vector map.

This is already possible using d.vect parameter legend_label.

Also, sometimes one has boundaries of countries or coastlines that should go on the map but doesn't need to have a label in the legend. If one disables the display of the map, it disappears from the legend, that's fine. But it would be great to be able to choose which items should have label and which shouldn't (but still be displayed).

That makes sense, I still have to think what would be the best way to implement it. Currently you can use d.legend.vect output parameter to export the legend definition, remove the particular line, and use it as input.

Thanks a lot!

in reply to:  1 ; comment:2 by mlennert, 8 years ago

Replying to annakrat:

Replying to veroandreo:

Hello,

I've been testing the new d.legend.vect and it is great :)

However, I found that it would be even better if one could change the label displayed. Not always the name of the vector map is the best option, especially if one is displaying for example only one category of an attribute. For instance, I have presence/absence points and only want to display presence points. I'd like to be able to tweak the label to be "presence" instead of the name of the vector map.

This is already possible using d.vect parameter legend_label.

Yes, but this does not seem to like spaces. If I use a label such as "Areas < 10e6" it only displays "Areas". Same with "Large Areas", I only get "Large" in the display. It does not make any difference if I enclose the text in quotes, or not.

Also, sometimes one has boundaries of countries or coastlines that should go on the map but doesn't need to have a label in the legend. If one disables the display of the map, it disappears from the legend, that's fine. But it would be great to be able to choose which items should have label and which shouldn't (but still be displayed).

That makes sense, I still have to think what would be the best way to implement it. Currently you can use d.legend.vect output parameter to export the legend definition, remove the particular line, and use it as input.

I tried just using one whitespace as lable, but then I get an 'x' in the display.

in reply to:  2 ; comment:3 by veroandreo, 8 years ago

Replying to mlennert:

Replying to annakrat:

Replying to veroandreo:

Hello,

I've been testing the new d.legend.vect and it is great :)

However, I found that it would be even better if one could change the label displayed. Not always the name of the vector map is the best option, especially if one is displaying for example only one category of an attribute. For instance, I have presence/absence points and only want to display presence points. I'd like to be able to tweak the label to be "presence" instead of the name of the vector map.

This is already possible using d.vect parameter legend_label.

Oh, I missed that one

Yes, but this does not seem to like spaces. If I use a label such as "Areas < 10e6" it only displays "Areas". Same with "Large Areas", I only get "Large" in the display. It does not make any difference if I enclose the text in quotes, or not.

Same here :(

Don't know how difficult it might be, but maybe it would be easier (and more visible, probably) from a user point of view, if that "legend_label" parameter would be integrated in d.legend.vect, instead of having to set the label in d.vect to then have it displayed with d.legend.vect

in reply to:  3 ; comment:4 by mlennert, 8 years ago

Replying to veroandreo:

Replying to mlennert:

Replying to annakrat:

Replying to veroandreo:

Hello,

I've been testing the new d.legend.vect and it is great :)

However, I found that it would be even better if one could change the label displayed. Not always the name of the vector map is the best option, especially if one is displaying for example only one category of an attribute. For instance, I have presence/absence points and only want to display presence points. I'd like to be able to tweak the label to be "presence" instead of the name of the vector map.

This is already possible using d.vect parameter legend_label.

Oh, I missed that one

Yes, but this does not seem to like spaces. If I use a label such as "Areas < 10e6" it only displays "Areas". Same with "Large Areas", I only get "Large" in the display. It does not make any difference if I enclose the text in quotes, or not.

Same here :(

Don't know how difficult it might be, but maybe it would be easier (and more visible, probably) from a user point of view, if that "legend_label" parameter would be integrated in d.legend.vect, instead of having to set the label in d.vect to then have it displayed with d.legend.vect

I prefer to have it in d.vect as that is where the layer is defined. In d.legend.vect, this would be awkward as a d.legend.vect call could concern anything from 1-X layers and so potentially you would need X text fields to define labels and X is not defined beforehand. So, I would plead to keep it as is, but just to improve the handling of special characters, including spaces, in the text.

in reply to:  4 ; comment:5 by veroandreo, 8 years ago

Replying to mlennert:

Replying to veroandreo:

Replying to mlennert:

Replying to annakrat:

Replying to veroandreo:

Hello,

I've been testing the new d.legend.vect and it is great :)

However, I found that it would be even better if one could change the label displayed. Not always the name of the vector map is the best option, especially if one is displaying for example only one category of an attribute. For instance, I have presence/absence points and only want to display presence points. I'd like to be able to tweak the label to be "presence" instead of the name of the vector map.

This is already possible using d.vect parameter legend_label.

Oh, I missed that one

Yes, but this does not seem to like spaces. If I use a label such as "Areas < 10e6" it only displays "Areas". Same with "Large Areas", I only get "Large" in the display. It does not make any difference if I enclose the text in quotes, or not.

Same here :(

Don't know how difficult it might be, but maybe it would be easier (and more visible, probably) from a user point of view, if that "legend_label" parameter would be integrated in d.legend.vect, instead of having to set the label in d.vect to then have it displayed with d.legend.vect

I prefer to have it in d.vect as that is where the layer is defined. In d.legend.vect, this would be awkward as a d.legend.vect call could concern anything from 1-X layers and so potentially you would need X text fields to define labels and X is not defined beforehand. So, I would plead to keep it as is, but just to improve the handling of special characters, including spaces, in the text.

ok, I see... Shall we then open a different enhancement ticket for "better handling of special characters and spaces in legend_label parameter of d.vect" and keep this one for the possibility of choosing which vector labels to show / not show in the vector legend??

in reply to:  5 ; comment:6 by mlennert, 8 years ago

Replying to veroandreo:

Replying to mlennert:

Replying to veroandreo:

Replying to mlennert:

Replying to annakrat:

Replying to veroandreo:

Hello,

I've been testing the new d.legend.vect and it is great :)

However, I found that it would be even better if one could change the label displayed. Not always the name of the vector map is the best option, especially if one is displaying for example only one category of an attribute. For instance, I have presence/absence points and only want to display presence points. I'd like to be able to tweak the label to be "presence" instead of the name of the vector map.

This is already possible using d.vect parameter legend_label.

Oh, I missed that one

Yes, but this does not seem to like spaces. If I use a label such as "Areas < 10e6" it only displays "Areas". Same with "Large Areas", I only get "Large" in the display. It does not make any difference if I enclose the text in quotes, or not.

Same here :(

Don't know how difficult it might be, but maybe it would be easier (and more visible, probably) from a user point of view, if that "legend_label" parameter would be integrated in d.legend.vect, instead of having to set the label in d.vect to then have it displayed with d.legend.vect

I prefer to have it in d.vect as that is where the layer is defined. In d.legend.vect, this would be awkward as a d.legend.vect call could concern anything from 1-X layers and so potentially you would need X text fields to define labels and X is not defined beforehand. So, I would plead to keep it as is, but just to improve the handling of special characters, including spaces, in the text.

ok, I see... Shall we then open a different enhancement ticket for "better handling of special characters and spaces in legend_label parameter of d.vect" and keep this one for the possibility of choosing which vector labels to show / not show in the vector legend??

Special characters (e.g. accents) are handled without problems. The only issue seems to be spaces.

For labels, a white space in the d.vect legend_label parameter might be an easy solution for not displaying labels.

When you say in your original ticket:

Also, sometimes one has boundaries of countries or coastlines that should go on the map but doesn't need to have a label in the legend.

are you really speaking about the labels, or about the fact that you would like to not have boundaries or coastlines in the legend at all ? If the former, maybe the white space option (or writing 'None' or something like that as the label) would be the easiest. If the latter, I guess the best solution would probably be adding an 'no legend label' flag to d.vect.

But you're right, I'll file a different ticket for the handling of spaces.

in reply to:  6 ; comment:7 by veroandreo, 8 years ago

Replying to mlennert:

Replying to veroandreo:

Replying to mlennert:

Replying to veroandreo:

Replying to mlennert:

Replying to annakrat:

Replying to veroandreo:

Hello,

I've been testing the new d.legend.vect and it is great :)

However, I found that it would be even better if one could change the label displayed. Not always the name of the vector map is the best option, especially if one is displaying for example only one category of an attribute. For instance, I have presence/absence points and only want to display presence points. I'd like to be able to tweak the label to be "presence" instead of the name of the vector map.

This is already possible using d.vect parameter legend_label.

Oh, I missed that one

Yes, but this does not seem to like spaces. If I use a label such as "Areas < 10e6" it only displays "Areas". Same with "Large Areas", I only get "Large" in the display. It does not make any difference if I enclose the text in quotes, or not.

Same here :(

Don't know how difficult it might be, but maybe it would be easier (and more visible, probably) from a user point of view, if that "legend_label" parameter would be integrated in d.legend.vect, instead of having to set the label in d.vect to then have it displayed with d.legend.vect

I prefer to have it in d.vect as that is where the layer is defined. In d.legend.vect, this would be awkward as a d.legend.vect call could concern anything from 1-X layers and so potentially you would need X text fields to define labels and X is not defined beforehand. So, I would plead to keep it as is, but just to improve the handling of special characters, including spaces, in the text.

ok, I see... Shall we then open a different enhancement ticket for "better handling of special characters and spaces in legend_label parameter of d.vect" and keep this one for the possibility of choosing which vector labels to show / not show in the vector legend??

Special characters (e.g. accents) are handled without problems. The only issue seems to be spaces.

For labels, a white space in the d.vect legend_label parameter might be an easy solution for not displaying labels.

When you say in your original ticket:

Also, sometimes one has boundaries of countries or coastlines that should go on the map but doesn't need to have a label in the legend.

are you really speaking about the labels, or about the fact that you would like to not have boundaries or coastlines in the legend at all ? If the former, maybe the white space option (or writing 'None' or something like that as the label) would be the easiest. If the latter, I guess the best solution would probably be adding an 'no legend label' flag to d.vect.

Sorry if I was not clear enough. What I mean is, I want boundaries or coastlines displayed in the map, but I don't want any legend or label for them. I was just imaging something like a tick box where you can select from the maps displayed which one you want legend for. For example, you have country boundaries, rivers and bridges and you want boundaries to be displayed in the final map, but you don't want a legend item for them, you only want legend items/labels for rivers and bridges. The problem is that currently, every map displayed have a line in the legend, unless you disable the map. But then, you don't get the boundaries displayed.

Hope it's clearer now :)

in reply to:  7 ; comment:8 by lazaa, 8 years ago

Replying to veroandreo:

Replying to mlennert:

Replying to veroandreo:

Replying to mlennert:

Replying to veroandreo:

Replying to mlennert:

Replying to annakrat:

Replying to veroandreo:

Hello,

I've been testing the new d.legend.vect and it is great :)

However, I found that it would be even better if one could change the label displayed. Not always the name of the vector map is the best option, especially if one is displaying for example only one category of an attribute. For instance, I have presence/absence points and only want to display presence points. I'd like to be able to tweak the label to be "presence" instead of the name of the vector map.

This is already possible using d.vect parameter legend_label.

Oh, I missed that one

Yes, but this does not seem to like spaces. If I use a label such as "Areas < 10e6" it only displays "Areas". Same with "Large Areas", I only get "Large" in the display. It does not make any difference if I enclose the text in quotes, or not.

Same here :(

Don't know how difficult it might be, but maybe it would be easier (and more visible, probably) from a user point of view, if that "legend_label" parameter would be integrated in d.legend.vect, instead of having to set the label in d.vect to then have it displayed with d.legend.vect

I prefer to have it in d.vect as that is where the layer is defined. In d.legend.vect, this would be awkward as a d.legend.vect call could concern anything from 1-X layers and so potentially you would need X text fields to define labels and X is not defined beforehand. So, I would plead to keep it as is, but just to improve the handling of special characters, including spaces, in the text.

ok, I see... Shall we then open a different enhancement ticket for "better handling of special characters and spaces in legend_label parameter of d.vect" and keep this one for the possibility of choosing which vector labels to show / not show in the vector legend??

Special characters (e.g. accents) are handled without problems. The only issue seems to be spaces.

For labels, a white space in the d.vect legend_label parameter might be an easy solution for not displaying labels.

When you say in your original ticket:

Also, sometimes one has boundaries of countries or coastlines that should go on the map but doesn't need to have a label in the legend.

are you really speaking about the labels, or about the fact that you would like to not have boundaries or coastlines in the legend at all ? If the former, maybe the white space option (or writing 'None' or something like that as the label) would be the easiest. If the latter, I guess the best solution would probably be adding an 'no legend label' flag to d.vect.

Sorry if I was not clear enough. What I mean is, I want boundaries or coastlines displayed in the map, but I don't want any legend or label for them. I was just imaging something like a tick box where you can select from the maps displayed which one you want legend for. For example, you have country boundaries, rivers and bridges and you want boundaries to be displayed in the final map, but you don't want a legend item for them, you only want legend items/labels for rivers and bridges. The problem is that currently, every map displayed have a line in the legend, unless you disable the map. But then, you don't get the boundaries displayed.

Hope it's clearer now :)

It's possible using input/output parameter. After adding all layers (boundary, rivers, bridges) you call d.legend.vect module with parameter output d.legend.vect -b at=10,40 output=legend_out.

You get file you can edit:

boundary|legend/area|5|139:105:20|227:227:186|3|area|8
rivers|legend/line|5|232:146:34|200:200:200|2|line|10837
bridges|basic/cross2|10|red|white|0|point|160

After deleting first line and saving file as e.g. legend_in you run d.legend.vect once again with input parameter d.legend.vect -b at=10,40 input=legend_in and you get legend with only two layers altough three layers are displayed in map window.

in reply to:  8 ; comment:9 by veroandreo, 8 years ago

Replying to lazaa:

[all the rest deleted]

It's possible using input/output parameter. After adding all layers (boundary, rivers, bridges) you call d.legend.vect module with parameter output d.legend.vect -b at=10,40 output=legend_out.

You get file you can edit:

boundary|legend/area|5|139:105:20|227:227:186|3|area|8
rivers|legend/line|5|232:146:34|200:200:200|2|line|10837
bridges|basic/cross2|10|red|white|0|point|160

After deleting first line and saving file as e.g. legend_in you run d.legend.vect once again with input parameter d.legend.vect -b at=10,40 input=legend_in and you get legend with only two layers altough three layers are displayed in map window.

Yes, Anna said before that that was the way to do it currently and this is probably useful for scripts, but maybe not very straightforward, especially for new users or those only using GUI.

in reply to:  9 comment:10 by mlennert, 8 years ago

Replying to veroandreo:

Replying to lazaa:

[all the rest deleted]

It's possible using input/output parameter. After adding all layers (boundary, rivers, bridges) you call d.legend.vect module with parameter output d.legend.vect -b at=10,40 output=legend_out.

You get file you can edit:

boundary|legend/area|5|139:105:20|227:227:186|3|area|8
rivers|legend/line|5|232:146:34|200:200:200|2|line|10837
bridges|basic/cross2|10|red|white|0|point|160

After deleting first line and saving file as e.g. legend_in you run d.legend.vect once again with input parameter d.legend.vect -b at=10,40 input=legend_in and you get legend with only two layers altough three layers are displayed in map window.

Yes, Anna said before that that was the way to do it currently and this is probably useful for scripts, but maybe not very straightforward, especially for new users or those only using GUI.

Yes, that's why I would suggest an additional flag to d.vect which if set would mean that this vector layer should not be part of the legend. This would then graphically translate into a checkbox in the 'legend' tab of the d.vect GUI.

comment:11 by mlennert, 8 years ago

I'm adding a patch proposal.

by mlennert, 8 years ago

Attachment: d.vect.legendflag.diff added

patch to add flag to not add layer to legend

comment:12 by annakrat, 8 years ago

In 69115:

d.vect: add flag to not put the layer in legend, see #3122

comment:13 by annakrat, 8 years ago

Resolution: fixed
Status: newclosed

Thanks, I was considering this solution too.

comment:14 by martinl, 8 years ago

Milestone: 7.3.07.4.0

Milestone renamed

Note: See TracTickets for help on using tickets.