Related
I installed the Guna theme which brings a nice color scheme that I would like to keep; however, the theme comes with a clock and weather widget that I can't remove even if I set the theme back to default.
I have tried setting the layer where the clock texture is contained, to have zero opacity, but then the most I got it to do was showing the clock in a different color.
The following lines are in the Guna theme's default settings, starting at line 166:
{
"class": "sidebar_container",
"layer0.texture": "Guna/assets/simple/sidebar/sidebar-bg-clock-nb.png",
"layer0.inner_margin": [15, 55, 15, 0],
//"layer0.inner_margin": [15, 70, 15, 0],
//"layer0.inner_margin": [15, 92, 15, 0],
"layer0.tint": "color(var(--background))",
"layer0.opacity": 1,
"content_margin": [0, 45, 0, 0],
//"content_margin": [0, 60, 0, 0],
//"content_margin": [0, 82, 0, 0],
},
{
"class": "sidebar_container",
"settings": ["gnwidgx"],
"layer0.texture": "Guna/assets/simple/sidebar/sidebar-bg-nb.png",
"layer0.inner_margin": [15, 55, 15, 0],
"layer0.tint": "color(var(--background))",
"layer0.opacity": 1,
"content_margin": [0, 0, 0, 0]
}
I tried setting the content margin to [0,0] for the clock widget (like I've seen it's possible to do to hide file icons), like so:
{
"variables": {
},
"rules":
[
{
"class": "sidebar_container",
"content_margin": [0,0],
"layer0.opacity": 0
},
{
"class": "sidebar_container",
"content_margin": [0,0],
"layer1.opacity": 0
}
]
}
And the result is this: every sidebar element, including the files and folders, bugs out and leaves a trail as if I were shift+dragging everything in mspaint.
Thanks in advance!
Apparently Guna has a setting that adds the widgets (clock, weather, etc.) to all themes. Fortunately, it can be turned off. Select Preferences → Package Settings → Guna → Settings and add the following to the right pane:
"sidebar_widget_on_other_theme": false,
You can turn off the widgets in Guna itself with this setting:
"sidebar_widget": [],
Valid values for that array are empty (as above) or any combination of "clock", "weather", and "date".
Save the right pane when you're done, and the settings should be applied immediately. If not, you might need to restart Sublime.
digit 5 monochrome image
How to convert the sample monochrome image to 2d array in ruby.
[[0, 0, 0, 0, 0],
[0, 1, 1, 1, 1],
[0, 1, 1, 1, 1],
[0, 0, 0, 0, 1],
[0, 1, 1, 1, 0],
[1, 1, 1, 1, 0],
[0, 1, 1, 1, 0],
[0, 1, 1, 1, 0],
[1, 0, 0, 0, 1]]
I had tried do it use pycall plugin. However, I had to import again manual when execute in rails console. Pycall not work sometimes.
require 'pycall'
require 'pycall/import'
include PyCall::Import
pyimport 'numpy', as: :np
pyimport 'PIL.Image', as: :pil_image
image = pil_image.open.(image_path).convert.('1')
img = np.asarray.(image, dtype: np.uint8)
list = img.tolist.().map { |l| l.to_a }
RMagick offers a couple of solutions. Use get_pixels to get an array of Pixel objects. Pixel objects are structures from which you can get the values of the red, green, and blue channel. Because the image is monochrome the channel values will either be 0 or QuantumRange. Scale the values by QuantumRange to force them to either 0 or 1.
Alternatively, use export_pixels. Again, scale the returned values by QuantumRange to get either 0 or 1.
In either case you can minimize the storage requirements (if your image is large) by operating on successive subsets (a single row, for example) of the image.
When marking tick locations on a plot, are there any standard solutions to how to place the tick markers? I looked at Matplotlib's MaxNLocator (https://github.com/matplotlib/matplotlib/blob/master/lib/matplotlib/ticker.py#L1212) but it's not immediately clear what all the different options do, or which of them are necessary for basic tick placement.
Can someone provide pseudocode for a simple tick location function?
I think the rule of thumb for placing ticks on a plot is to use multiples of 1, 2, 5, and 10. In my experience, matplotlib seems to abide by this. If you have reason to deviate from the default ticks, I think the easiest way to set them is to use the set_ticks() method for a particular axis. The relevant documentation is here: http://matplotlib.org/api/axis_api.html.
Example
import numpy as np
import matplotlib.pyplot as plt
ax = plt.subplot() # create axes to plot into
foo = np.array([0, 4, 12, 13, 18, 22]) # awkwardly spaced data
bar = np.random.rand(6) # random bar heights
plt.bar(foo, bar) # bar chart
ax.xaxis.get_ticklocs() # check tick locations -- currently array([ 0., 5., 10., 15., 20., 25.])
ax.xaxis.set_ticks(foo) # set the ticks to be right at each bar
ax.xaxis.get_ticklocs() # array([ 0, 4, 12, 13, 18, 22])
plt.draw()
ax.xaxis.set_ticks([0, 10, 20]) # minimal set of ticks
ax.xaxis.get_ticklocs() # array([ 0, 10, 20])
plt.draw()
Of the three options in my example, I would keep the default behaviour in this case; but there are definitely times when I would override the defaults. For example, another rule of thumb is that we should minimize the amount of ink in our plots that is not data (i.e. markers and lines). So if the default tick set was [0, 1, 2, 3, 4, 5, 6], I might change that to [0, 2, 4, 6], since that's less ink for the plot ticks without losing clarity.
Edit: The ticks at [0, 10, 20] can also be accomplished with locators, as suggested in the comment. Examples:
ax.xaxis.set_major_locator(plt.FixedLocator([0,10,20]))
ax.xaxis.set_major_locator(plt.MultipleLocator(base=10))
ax.xaxis.set_major_locator(plt.MaxNLocator(nbins=3))
I'm in the process of creating a notebook that contains a style to write documents. I would like Mathematica to behave similar to LaTeX in the sense that when I write a "Definition" cell then it will write "Definition [Chapter#].[Definition#]".
To see what I mean do the following. In an empty notebook create a cell and modify the style to "Chapter". You can do this by selecting the cell and the going to Format->Style->Other, enter "Chapter".
Now go to Format->Edit StyleSheet.... Enter Chapter in the input box. This will generate a cell labeled Chapter. Select that cell, and click on Cell->Show Expression. At this point select all that text that you see there and replace it with the following:
Cell[StyleData["Chapter"],
CellFrame->{{0, 0}, {0, 0}},
ShowCellBracket->Automatic,
CellMargins->{{42, 27}, {10, 30}},
CounterIncrements->"Chapter",
CounterAssignments->{{"Section", 0}, {"Definition", 0}},
FontFamily->"Verdana",
FontSize->24,
FontWeight->"Bold",
CellFrameLabels->{{
Cell[
TextData[{
"Chapter ",
CounterBox["Chapter"]
}], "ChapterLabel", CellBaseline -> Baseline], Inherited}, {
Inherited, Inherited}},
FontColor->RGBColor[0.641154, 0.223011, 0.0623026]]
This will change the style of how a chapter cell is displayed. I changed the color and font. The most important thing to me is the CellFrameLabels. Noticed that I have made it so that every time you create a chapter cell it will display: Chapter [Chapter Number].
In the picture above I have created several chapter cells and I have added the text: ": Title of Chapter #".
This is simple enough, we can create any cell, apply a definition and take advantange of counters to label the cells.
I have noticed how some books have definitions enclosed in box. So in this case I would like to create a box that contains Definition. Here is my lame attempt with the definition of the cell "Definition".
Cell[StyleData["Definition"],
CellFrame->{{0, 0}, {0, 2}},
ShowCellBracket->Automatic,
CellMargins->{{27, 27}, {0, 8}},
PageBreakWithin->False,
CellFrameMargins->16,
CellFrameColor->RGBColor[0.641154, 0.223011, 0.0623026],
Background->RGBColor[0.963821, 0.927581, 0.844465],
FontFamily->"Verdana",
CounterIncrements->"Definition",
FontSize->12,
CellFrameLabels->{{
Cell[
TextData[{
"Definition ",
CounterBox["Chapter"], ".",
CounterBox["Definition"]
}], "DefinitionLabel", CellBaseline -> Baseline], Inherited}, {
Inherited, Inherited}},
]
Here is how it looks in the notebook:
Here is the question: Is there a way to make the CellFrameLabels part of the cell? I want the label to have the same background and to be inline with the other text. Here is a screen shot of how I want it to look:
I have made the "label" bold font and blue. This is something that the user should not be able to modify.
I don't think that it's possible to do in the way you want. CellLabels can only be text, while both CellDingbat and CellFrameLabels can be arbitrary cell expressions.
Both CellDingbat -> ... and CellFrameLabels -> {{...,None},{None,None}} work if the cell is only a single line long. But do not automatically resize for multiple line cells (at least as far as I could tell). For example:
Cell["Abcdefg", "Text",
CellFrame->{{0, 1}, {0, 2}},
CellMargins->{{30, 24}, {6, 6}},
CellFrameMargins->0,
CellFrameColor->RGBColor[0, 0, 1],
CellFrameLabels->{{Cell[" Definition 1.1 ", "Text",
CellFrame -> {{2, 0}, {0, 2}}, CellFrameMargins -> 0], None}, {None, None}},
CellFrameLabelMargins->0,
Background->RGBColor[0, 1, 1]]
Putting a CellFrameLabel on the top does not have this problem, but I don't know how to align it to the left...
Cell["Abcde", "Text",
CellFrame->{{1, 1}, {0, 2}},
CellMargins->{{30, 24}, {6, 6}},
CellFrameMargins->0,
CellFrameColor->RGBColor[0, 0, 1],
CellFrameLabels->{{None, None}, {None,
Cell[" Definition 1.1 ", "Text",
CellFrame -> {{2, 2}, {0, 2}}, CellFrameMargins -> 0]}},
CellFrameLabelMargins->0,
Background->RGBColor[0, 1, 1]]
I think that maybe the best looking solution would be to include the "Definition ch.def:" in the cell contents.
Cell[TextData[{
Cell["Definition 1.1: ", Editable->False, Selectable->False, Deletable->False],
"Abcdefg"}], "Text",
CellFrame->{{1, 1}, {0, 2}},
CellMargins->{{30, 24}, {6, 6}},
CellFrameColor->RGBColor[0, 0, 1],
Background->RGBColor[0, 1, 1]]
Make it so that it's not deletable by the average user and it is probably almost as good as a cell(frame)label. It can include counters so that it automatically shows the correct numbering. The only problem is that it does not appear automatically, but if you just copy a pre-existing cell, then that's not too much of a problem.
Edit: Adding an input alias that creates the non-deletable counter
First we get the current input aliases,
oldAliases = InputAliases /. Options[EvaluationNotebook[], InputAliases];
then replace any existing alias EscdefEsc with our new one:
newAliases =
Append[DeleteCases[oldAliases, "def" -> _],
"def" -> Cell[TextData[
RowBox[StyleBox[#, FontWeight->"Bold", FontColor->Blue]&/#{"Definition ",
CounterBox["Chapter"], ".", CounterBox["Definition"], ": "}]],(*"Text",*)
Editable -> False, Selectable -> False, Deletable -> False]];
SetOptions[EvaluationNotebook[], InputAliases -> newAliases]
Since I don't have your style sheet, I need to set a couple of counters:
CellPrint[Cell["Setting the counters", "Text",
CounterAssignments -> {{"Chapter", 2}, {"Definition", 3}}]]
Now I can use the alias in an existing cell - it inherits the styling of the parent cell (unless otherwise specified):
Another option is to make a palette to go with your stylesheet. This would be useful since there's only a limited number of MenuCommandKey values that you can use for your new styles (n.b. overwriting the default ones will just confuse people). See this answer for an example of such a palette.
Exporting to animated gif seems to have changed in Mathematica 8.0.1?
I normally make animated GIFs of a manipulate by simply writing:
v=Manipulate[....]
then Export["foo.gif",v];
But now it does not work. I just get one static image.
Here is an example:
v=Manipulate[
Text[t],
{{t,4,"start"},0,10,1,ControlType->Trigger,AnimationRate->1,AnimationRepetitions->10}
]
Now Export["foo.gif",v] just generate static image, as nothing was running.
But Export["foo.avi",v] works, and it does generate a running avi movie.
Also, there used to be animated GIF options I used before, but now there are not supported:
Export["foo.gif",v,ConversionOptions->{"AnimationDisplayTime"->0.5,"Loop"->True},ImageSize->{500,500}]
Export::convoptobs: ConversionOptions is obsolete.
When I go to help, I do not see options for GIF there. How does one control animation delay and such?
I thought someone here might have an idea.
thanks
--Nasser
You can export a Table to an animated GIF.
v = Table[Panel[Text[t]], {t, 0, 10, 1}];
Export["anim.gif", v, "DisplayDurations" -> 0.5]
If you absolutely want the animation to look like a Manipulate, you could do something like so.
v = Table[Manipulate[Text[t],
{{t, Mod[k, 10], "start"}, 0, 10, 1, ControlType -> Trigger}],
{k, 4, 14}];
Export["Manip.gif", v, "DisplayDurations" -> 0.5]
You can use v = Animate[
Text[t], {{t, 4, "start"}, 0, 10, 1, ControlType -> Trigger,
AnimationRate -> 1, AnimationRepetitions -> 10}]