Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Gradient Button On Colour tab In Plot Options Sub Dialog. #8733

Merged
merged 17 commits into from
Feb 29, 2024

Conversation

MeSophie
Copy link
Contributor

Fixes #8623.
@rdstern @lilyclements I added the gradient button on color tap. Please have a look.

@rdstern rdstern changed the title Added Gradient Button On Colour tap In Plot Options Sub Dialog. Added Gradient Button On Colour tab In Plot Options Sub Dialog. Jan 16, 2024
@rdstern
Copy link
Collaborator

rdstern commented Jan 30, 2024

@lilyclements could you check and approve. You are better at colours than me!

Copy link
Collaborator

@rdstern rdstern left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MeSophie that's a nice addition and it seems to work too!

image

a) The sub-dialog has become excessively wide, see above.
b) The range of colours for the gradient is very small. Usually it is linger and with an option to choose one:

image

c) The setting of discrete at the top right always resets. I made it continuous when it was needed, and it didn't remember. The next time I returned there it has reset to discrete..

Here is a nice looking heatmap, making use of the gradient and going from Yellow to Blue!

image

@MeSophie
Copy link
Contributor Author

MeSophie commented Feb 5, 2024

@rdstern Could you please test the change? For c) the control always resets the old value because it automatically detects the value of the receiver y. For cases such as histogramm and bar plots, the control value remains discrete because it is the default value and there is no y variable.

Copy link
Collaborator

@rdstern rdstern left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MeSophie the width of the dialog is now resolved.
a) The high option now has the bigger set of colours. But could you please add the pick colour option too?
b) The low is still short. Is that intentional? Could that become the same as the High option?
c) In the dialog I changed and used Pastel1 as the palette. If I then change discrete to continuous or vice versa, it resets the palette to the default of Accent. And it is reset to the default of Accent, each time I return to the tab. That also happens with other options, e.g. divergent, that use that control.
image

d) In the heatmap dialog the setting of the colours (discrete or continuous) depends on the fillcontrol in the dialog:

image

Usually, as here, it is numeric, so continuous. But it can be a factor, in which case discrete is needed. Can this be detected, and become automatic on the colour tab? If it has to be a single setting for the dialog, then usually it will be numeric, and so continuous.

@MeSophie
Copy link
Contributor Author

MeSophie commented Feb 7, 2024

@rdstern I solved part a), b) and c). For part d) I'm still investigating on it.

@MeSophie MeSophie marked this pull request as draft February 15, 2024 08:39
Copy link
Collaborator

@rdstern rdstern left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MeSophie I'm getting build errors?

@MeSophie
Copy link
Contributor Author

@MeSophie I'm getting build errors?

@rdstern I'm still working on it. I'll let you know when I'm done.

@MeSophie MeSophie marked this pull request as ready for review February 16, 2024 09:10
@MeSophie
Copy link
Contributor Author

@rdstern Could you please check the dialog ?

@rdstern
Copy link
Collaborator

rdstern commented Feb 16, 2024

@MeSophie this still seems to bed giving you various troubles. I tried with the usual survey, bar chart, village by variety and then your colour an gradient.
Here is the sub-dialog and correctly remembering what I tried before:
image

When I run it gives an error and I can see why. Here is the code generated:

# Dialog: Bar Chart

survey <- data_book$get_data_frame(data_name="survey")
last_graph <- ggplot2::ggplot(survey, mapping=ggplot2::aes(x=village, fill=variety)) + ggplot2::geom_bar(stat="count") + scale_fill_gradient() + theme_grey()
data_book$add_object(data_name="survey", 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="survey", object_name="last_graph", as_file=TRUE)
rm(list=c("last_graph", "survey"))

It has ignored all the options in scale_fill_gradient(). And just given it like this!

@N-thony there is also a more general oddity, which seems far worse here than before. The first time you click on the Plot Options it takes ages to go into them. In general at least 5 seconds, but perhaps more obviously here, it took over 25 seconds. Could you investigate, either in this pull request, or more generally in a new pull request? Where is it going in the code the first time that takes so long - and also isn't needed after that?

@MeSophie
Copy link
Contributor Author

@rdstern the message error was because I didn't put the appropriate function for discrete scale. I added scale_fill_manual and scale_colour_manual function. Could you please test the dialog again?

@MeSophie
Copy link
Contributor Author

MeSophie commented Feb 20, 2024

@rdstern by testing the new change in Boxplot dialog with our survey data, As shown in the figure below, detection in the colour tap of our plot options sub dialog executes perfectly as a function of the variable Y. When we click Return and then Ok, we get an error message saying discrete value supplied to continue scale. This is because the fill value is discrete and the scale fill function used is continuous. Would it be a good idea to carry out the detection here according to the fill parameter, as we did in the HeatMap Dialog?

image

@MeSophie
Copy link
Contributor Author

@rdstern please anything new about this PR?

@rdstern
Copy link
Collaborator

rdstern commented Feb 27, 2024

@MeSophie yes I have just read your question above again. You are right. In this dialog it is the fill that is being coloured, not the y variable. So it should detect when that is a factor and then use discrete.

@MeSophie
Copy link
Contributor Author

@rdstern Could you please check the new change?

@MeSophie yes I have just read your question above again. You are right. In this dialog it is the fill that is being coloured, not the y variable. So it should detect when that is a factor and then use discrete.

@rdstern Could you please check the new change?

rdstern
rdstern previously approved these changes Feb 28, 2024
Copy link
Collaborator

@rdstern rdstern left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MeSophie great. @N-thony this is quite a big change. When you are happy it will be good to mergs.

@@ -56,6 +56,7 @@ Public Class dlgBoxplot
Private clsXScaleDateFunction As New RFunction
Private clsYScaleDateFunction As New RFunction
Private clsFacetsFunction As New RFunction
Private Fillvariable As Boolean = True
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you rename this variable for something more descriptive of it purpose?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is solved.

@@ -19,6 +19,7 @@ Public Class dlgHeatMapPlot
Private bFirstLoad As Boolean = True
Private bRCodeSet As Boolean = True
Private bReset As Boolean = True
Private Fillvariable As Boolean = True
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you need this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is solved.

@@ -554,7 +555,7 @@ Public Class dlgHeatMapPlot
clsNewScaleFillViridisFunction:=clsScaleFillViridisFunction, clsNewScaleColourViridisFunction:=clsScaleColourViridisFunction, clsNewYLabTitleFunction:=clsYlabFunction, clsNewLabsFunction:=clsLabsFunction,
clsNewFacetFunction:=clsRFacetFunction, clsNewThemeFunction:=clsThemeFunction, dctNewThemeFunctions:=dctThemeFunctions, ucrNewBaseSelector:=ucrHeatMapSelector, clsNewFacetVariablesOperator:=clsFacetVariablesOperator,
strMainDialogGeomParameterNames:=strGeomParameterNames, clsNewCoordPolarFunction:=clsCoordPolarFunction, clsNewCoordPolarStartOperator:=clsCoordPolarStartOperator,
clsNewAnnotateFunction:=clsAnnotateFunction, clsNewXScaleDateFunction:=clsXScaleDateFunction, clsNewYScaleDateFunction:=clsYScaleDateFunction, bReset:=bResetSubdialog)
clsNewAnnotateFunction:=clsAnnotateFunction, clsNewXScaleDateFunction:=clsXScaleDateFunction, clsNewYScaleDateFunction:=clsYScaleDateFunction, NewFillvariable:=True, bReset:=bResetSubdialog)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same with NewFillvariable

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is solved.

@@ -108,6 +110,7 @@ Public Class sdgPlots
Private dctDivergingPairsContinuous As New Dictionary(Of String, String)
Private dctQualititivePairsContinuous As New Dictionary(Of String, String)
Public strAxisType As String
Public Fillvariable As Boolean = False
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you need this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@N-thony I thing this question is for Boxplot dialog. If so this is solved.

@@ -108,6 +110,7 @@ Public Class sdgPlots
Private dctDivergingPairsContinuous As New Dictionary(Of String, String)
Private dctQualititivePairsContinuous As New Dictionary(Of String, String)
Public strAxisType As String
Public FillAesdetection As Boolean = False
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for Boolean type we always name a variable by starting with small b see line 72.
But my question is to understand if you need it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is Solve and I added the b on FillAesdetection and NewFillAesdetection

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you need line 113

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you need line 113

@N-thony I deleted this line

End Sub

Public Sub SetRCode(clsNewOperator As ROperator, clsNewCoordPolarFunction As RFunction, clsNewCoordPolarStartOperator As ROperator, clsNewYScalecontinuousFunction As RFunction, clsNewXScalecontinuousFunction As RFunction, clsNewLabsFunction As RFunction,
clsNewXLabsTitleFunction As RFunction, clsNewYLabTitleFunction As RFunction, clsNewFacetFunction As RFunction, clsNewThemeFunction As RFunction, dctNewThemeFunctions As Dictionary(Of String, RFunction), ucrNewBaseSelector As ucrSelector,
bReset As Boolean, Optional clsNewGlobalAesFunction As RFunction = Nothing, Optional clsNewXScaleDateFunction As RFunction = Nothing, Optional clsNewYScaleDateFunction As RFunction = Nothing, Optional clsNewFacetVariablesOperator As ROperator = Nothing,
Optional clsNewScaleFillViridisFunction As RFunction = Nothing, Optional clsNewScaleColourViridisFunction As RFunction = Nothing, Optional strMainDialogGeomParameterNames() As String = Nothing, Optional clsNewAnnotateFunction As RFunction = Nothing,
Optional bNewEnableFill As Boolean = True, Optional bNewChangeScales As Boolean = False, Optional bNewEnableColour As Boolean = True, Optional bNewEnableDiscrete As Boolean = True, Optional strNewAxisType As String = "discrete")
Optional bNewEnableFill As Boolean = True, Optional NewFillAesdetection As Boolean = False, Optional bNewChangeScales As Boolean = False, Optional bNewEnableColour As Boolean = True, Optional bNewEnableDiscrete As Boolean = True, Optional strNewAxisType As String = "discrete")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bChangeAesParameter instead of NewFillAesdetection?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is solved

Copy link
Collaborator

@rdstern rdstern left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MeSophie I again tried for a nice gradient with this:
image

It is working nicely for me! @N-thony I am happy the code is becoming more solid, and am approving again.

@N-thony N-thony merged commit fbe6939 into IDEMSInternational:master Feb 29, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

colour scale graph in R-Instat?
3 participants