Closed rdstern closed 1 year ago
@lloyddewit when trying to make title name change for this dialogue, it did not have the name change as expected.... does this need another change in the database before it shows the change?
@derekagorhom yes, you are correct, we'll need to change the database before you see the name change. I'm currently working on the database so I will make the change for you in a different PR. I assume that only part a)
requires a database change. Is that correct?
@lloyddewit yes... thank you for the quick response
I have now found items d), e), f) and g) to add, and there may be more as I (and @COLIEWO ) test the dialogue more, particularly on pie and donut charts!
d) Make Stack the default for the Position, when there are 2 factors. It is now the default position setting for the geom and I see no reason to be different for R-Instat. So the order should change. Stack becomes the first, next is Fill and third is Dodge. Then the rest.
e) The last option is Stack in Reverse. Add, after that, a further oprion namely - obviously - Fill in Reverse. it is given in the geom_bar as follows: `ggplot2::geom_bar(position=position_fill(reverse=TRUE)
f) When I used the option Fill I lost the legend! I notice that was simply because, for that option, the code + ggplot2::theme(legend.position="none")
was added. Please delete it. We should worry about the legends generally, but that's different.
Perhaps @COLIEWO can check that the R-code generated is consistent for the different options.
g) Bar charts when using a numeric variable.
The bar chart can even be used when the x variable is numeric, rather than a factor, - though it is often not very sensible. When this is a variate, as shown above than the ascending and descewnding options don't work, and give an error. The correction is simple.
Here is the code generated -
last_graph <- ggplot2::ggplot(diamonds, mapping=ggplot2::aes(x=forcats::fct_infreq(f=carat), fill="")) + ggplot2::geom_bar(position="dodge", stat="count") + theme_grey()
The descending option has added x=forcats::fct_infreq(f=carat)
. Please add an as.factor, to the code for both ascending and descending, so it becomes x=forcats::fct_infreq(f=as.factor(carat))
b) None of the 3 controls Reorder Frequency, Reorder and Position remember their settings when you re-open the dialogue. They should all remember. @lloyddewit Derek mentioned that you may be doing something to fix this? I now note that this control was ok in Version 0.7.6. I wonder what has happened?
@derekagorhom please note that PR #8293 may solve (some of) these issues.
On the Add Labels feature, is it possible to specify the variable like in the Scatter Plot dialog? Currently it automatically picks the Single Variable.
@derekagorhom I suggest a correction for the bar chart label for position 'In' whose part code is currently geom_text(stat="count", mapping=ggplot2::aes(label=..count..), position=position_dodge(width = 0.9), vjust=5, colour="black", size=4)
whose output is as below (this is just one example where the 'fair' category labels are misplaced);
Fig. 1 | Fig. 2 |
---|---|
Changing vjust=5
to vjust=1.5
makes the labeling better (reducing the size of the labels makes it better);
Performing some basic functions in the bar chart dialog gave below insight. Plotting ‘cut’ with color ‘cut’
Fig 1 | Fig 2 |
---|---|
The code generated by the dialog
diamonds <- data_book$get_data_frame(data_name="diamonds") last_graph <- ggplot2::ggplot(diamonds, mapping=ggplot2::aes(x=cut, fill="")) + ggplot2::geom_bar(mapping=ggplot2::aes(colour=cut), position="dodge", stat="count") + theme_grey() + ggplot2::theme(axis.text.x=ggplot2::element_text()) data_book$add_object(data_name="diamonds", object_name="last_graph", object_type_label="graph", object_format="image", object=check_graph(graph_object=last_graph)) data_book$get_object_data(data_name="diamonds", object_name="last_graph", as_file=TRUE) rm(list=c("last_graph", "diamonds"))
The plot output is as shown below (the data labels are a bit confusing) with the expected output to the right (this is achieved by deleting ,fill=""
, from the code);
Fig 3 | Fig 4 on deleting fill="" |
---|---|
Plotting ‘cut’ with alpha ‘color’ with position ‘dodge’
Fig 5 | Fig 6 |
---|---|
The plots; | Fig 7 | Fig 8 on deleting fill="" |
---|---|---|
These tests imply that when the By Factor (Optional) field isn’t filled and under Layer Options -> fill option isn’t filled either, it tends to mess with the plot output (legend labels).
If I decide to include facets in the main bar chart dialogue under plot options, two factor options pop up. The first factor option is mandatory, while the second factor option is optional. To enhance user-friendliness, I was contemplating an automatic filling of the "first factor option" when there is only a single factor variable.
@rdstern @derekagorhom I suggest 2 edits to the Treemap dialog for the moment;
‘Start’ and ‘Layout’ do not maintain the values when you reopen the dialog
“Middle” place for labels isn’t positioned well, the output is for "Topleft"
Sheet1 <- data_book$get_data_frame(data_name="Sheet1") last_graph <- ggplot2::ggplot(Sheet1, mapping=ggplot2::aes(area=as.numeric(Population), fill=City)) + treemapify::geom_treemap() + treemapify::geom_treemap_text(mapping=ggplot2::aes(label=City)) + theme_grey() data_book$add_object(data_name="Sheet1", object_name="last_graph", object_type_label="graph", object_format="image", object=check_graph(graph_object=last_graph)) data_book$get_object_data(data_name="Sheet1", object_name="last_graph", as_file=TRUE) rm(list=c("last_graph", "Sheet1"))
Edit code to + treemapify::geom_treemap_text(mapping=ggplot2::aes(label=City),place=’middle’)
Fig 1 Initial plot | Fig 2 On editing |
---|---|
@N-thony here is a reference on bar and pie charts
I hope (in the sprint) we can get a set of options, so we can get "ordinary" pie charts. It may be that we just need to choose the options correctly, but I don't know how to do that with a single variable, in the dialog?
Also a serious bug I reported. Do a very simple bar chart, say survey data and village. Then use the plot options down arrow and choosefor the bar chart. Then don't do anything, just return. Then press Ok and you get an error.
I assume that's because there are no x variable. It used to be ok. Here it is in Version 7.6:
@N-thony at last I can get (proper) pie charts from our existing bar chart dialog. But not quite how I would like. I use our usual survey data. For a simple pie chart I make a new column that is a constant - say 1 everywhere - I call it calc.
Then without polar it is this:
And, changing to Polar gives this!
And notice the calc (always 1) is now the y variable.
If I put Variety instead of the dummy column, then I get nice donut charts:
Then we need to use the Fill option. Stack is quite fun and may sometimes also be of interest.
Maybe @COLIEWO could check whether the labelling works on this?
I am releived that we can do this. I wonder whether we keep to this way - which is sort of odd for the simple pie (having to make a dummy variable), but not impossible. Or do we swap the variables round for a pie, and make a dummy variable when we need to?
On reflection @N-thony I suggest someone this week tries to change the R-code for the pie and donut charts, when there is just a single variable - so no by factor. In that case it "quietly" makes the constant x-variable and turns the single variable into the by - so roughly as shown above. That's the only change. We leave the code as now, if there is a by factor included. I hope that can be started this week, perhaps by @COLIEWO if she has time. If not, then could it be allocated to either ana or esther. It should not take long, and I hope @lilyclements could check the code. If they can't, (and they shouldn't spend much time on it.) then I hope the R-code could easily be given by Lily. If it takes a long time, then we can stick with the current situation, where the user has to add a constant variable. That will anway remain an option.
At the same time I like the point made by @COLIEWO about the treemap. I hope that can be fixed.
And once we have the pie charts can someone check that they can also be labelled easily.
@N-thony I have just found a serious bug in the new bar chart dialog. I assume it must have come from the recent improvements, because it is not there in Version 0.7.6.
When I use the Plot options it does not include the geom's aethestics - the x and y, see below.
So then it gives an error when you try to run.
This seems to be general, so for any data set and for any of the options, e.g also for treeplot.
@anastasia-mbithe can you have a look of this? Let me know if you need help.
@COLIEWO is working on this topic, and so this issue may partly be dealt with elsewhere. @derekagorhom I hope you can start on these points, and @COLIEWO will be the main tester. Perhaps @WezzieBanda also
Here is the current bar chart dialogue:
a) Change the title to just
Bar Charts
. (We don't give much importance to Pie Charts, so let's not keep it in the title.) b) None of the 3 controlsReorder Frequency, Reorder and Position
remember their settings when you re-open the dialogue. They should all remember. @lloyddewit Derek mentioned that you may be doing something to fix this? I now note that this control was ok in Version 0.7.6. I wonder what has happened? c) The position of the 3 addutionalAdd Labels
controls is messy. And they are incomplere in Russian - at least. I suggest moving all 3 to be on the same horizontally, withPosition
moved to perhaps start just below the A of Add Labels. Maybe the same horizontally asColour and Size
, so moving the Add Labels checkbox up slightly. Check that each label is wide enough that is shows completely in Russian, and maybe also check the French also.@COLIEWO is likely to be adding to this issue as we explore the dialogue more fully