Akademy-BR: changing axis labels in KmPlot April 19, 2010Posted by Filipe Saraiva in planetkde-filipesaraiva.
Between 9th and 11th April I was in Praia do Forte, Bahia, attending Akademy-BR: a meeting for developers, enthusiasts, and other members of Brazilian KDE community.
My main goal was to work with the KDE-Edu, especially in Rocs, KAlgebra, and KmPlot. Among these, I turned mainly to the last one because I was playing a bit with it some weeks ago.
In a course at USP, I needed to plot a two-dimensional graph to display solutions of linear programming problems. No big deal, it would be done very well in gnuplot, for example, but I decided to try KmPlot in order to get more used to KDE-Edu tools.
I realized then that the software, unfortunately, didn’t have an option to change the labels of the coordinate axis. I asked myself: “oh god, such an educational software should have that option”. It soon came to my mind a student’s primary or secondary education, wanting to use the software and plotting graphs with all their coordinates labeled “X” and “Y” 🙂
Conventional KmPlot’s diagram
I also remembered the lessons of those graphics and physics like “Velocity” according to “Time”. A physics teacher could not make efficient use of KmPlot in this example. I remembered me studying physics at school and I thought I would feel frustrated when trying to use KmPlot charts with “X” and “Y”. Then, taking to me the task of turning around this fact, falls into the field to implement this functionality.
This is the original window in the Configuration tab in the Diagram. Note that there are several options how to show the grid, the width axis, line, display labels and more. As that window set directly on the diagram, I added the functionality here to change the labels.
Configuration Diagram to Change Labels
We included a GroupBox “Axis Label” and its options “Label to Horizontal Axis” and “Label to Vertical Axis“. In LineEdit’s next, the user can insert the character or word they think more convenient.
In this simple example, I adjusted Velocity and Time to satisfy our physical friends. In addition, of course, bring us the good memories of our classes in high school 🙂
Modified diagram with labels
Voilà! We now graph the velocity as a function of time. Also interesting to note that the change affects only the labels: editing the formula continues to use “X” and “Y” normally.
Window Coordinate Systems following new standard
I also made some corrections to follow the pattern that this new functionality required. In this case, the window of Coordinate Systems had the titles of your GroupBox’s changed to reference axis “Horizontal Axis” and “Vertical Axis” instead of “X” and “Y” as it was before.
So folks, that was some of my humble contribution to KDE made during Akademy-BR. I hope it is the first of many ones! The next step is to create the patch and send it to authors and maintainers of KmPlot. I hope they enjoy this work as much as I liked to have done it.
Could not finish this post without a graph of
Velocity as a function of Time
See you !!!